Hi,
The above code cause a Runtime check failure #2. (The file is getting written to though).
Does anyone know what is causing this ?
Thanks in advance.
Rich.
WinXP SP2, MSVC 2005.
Code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
char cPath[MAX_PATH];
ZeroMemory(cPath,MAX_PATH);
GetModuleFileName(NULL,cPath,MAX_PATH);
// cPath = "c:\Documents and Settings\rich\My Documents\Visual Studio Projects\C++\cTest2\Debug\cTest2.exe"
strcpy_s(strrchr(cPath,'\\')+1,MAX_PATH,"File.tmp");
// cPath = "c:\Documents and Settings\rich\My Documents\Visual Studio Projects\C++\cTest2\Debug\File.tmp"
FILE *fp = NULL;
fopen_s(&fp,cPath,"w");
fputs("hello\n",fp);
fclose(fp);
return 0;
} // <-- message appears here
The above code cause a Runtime check failure #2. (The file is getting written to though).
Does anyone know what is causing this ?
Thanks in advance.
Rich.
WinXP SP2, MSVC 2005.