I have code in a VC6 application to read and write to a text file. The code works fine. However, this same code in a VS2005 application does not work. It compiles without error, and the reading works properly (as I can see by stepping thru the code in the debugger). However, the file writing does NOT work. Instead, the file is not getting written to, even though in the debugger the code to write to the file IS getting executed.
Here's a code sample:
f.open(strMyFileName, ios::in | ios::out);
CString strStuffToWrite = "Some Cool Stuff To Write to the File";
char* charForWritingToFile = NULL;
f.read(charForReadingBlankLine, 2);//advance past the first blank line in the file
charForWritingToFile = (char*)malloc(strlen(strStuffToWrite) + 1);
strcpy_s(myChar, strlen(strStuffToWrite) + 1, strStuffToWrite); //.net
So again, this code runs, but when I open the file after it has run, the file is unchanged, i.e., the stuff I wanted to write to the file has NOT replaced the stuff that was ORIGINALLY in the file. (Yet in VC6 this code worked perfectly)
Any help would be greatly appreciated.