static void OpenFiles(char filname[],int opt)
{
if (opt==1)
g_inputfilepointer= fopen(filname, "w");
if (opt==2)
g_inputfilepointer= fopen(filname, "r");
}
Program compiles ok but using the following call my error message is triggered
OpenFiles,( L"Location",1);
if (g_inputfilepointer==NULL)
{
MessageBox(g_hwnd, L"Could not open Location
File.", L"Error", MB_OK | MB_ICONERROR);
}
g_inputfilepointer is a global file pointer
Any advice as to where i am going wrong would be great
I have searched around a bit and read something that seemed to say that i had to declare the full path??
BTIA grom-it
You should use the widechar version of fopen:
static void OpenFiles(wchar filname[],int opt)
{
if (opt==1)
g_inputfilepointer= _wfopen(filname, L"w");
if (opt==2)
g_inputfilepointer= _wfopen(filname, L"r");
}
Thanks Frankie but i could not get one created let alone opened
using wchar_t
as in
static void OpenFiles(wchar_t filname[],int opt)
{
i am still triggering file not opened message
i have even tried a full path
using
HINSTANCE hInstance = GetModuleHandle(NULL);
wchar_t szFileName[MAX_PATH];
GetModuleFileName(hInstance,szFileName, MAX_PATH);
Still no joy
Is this something to do with WM5 ?????
should i use createfile structure in win32 API ??????
any further advice would be useful...
BTIA grom-it
I am going to answer my own question here
just to bring this thread to an end
The reason i could not get a file pointer was because of this line here in my original question
OpenFiles,( L"Location",1);
notice the comma after the openFiles call
left in it compiles but does not work
left out and i get a file pointer
;D :D :D :D
Thanks for your help on the wchar aspect frankie
It does look like my original guff was a typo............