This is my first time using C and my first time posting so experts out there please be patient with me. I'm trying to write a file starting with one line and then append text to that file.
So far the only code that has been able to even produce the file is as follows:
char *szTestFile;
HANDLE hTestFile;
char szirdCreateFile[16];
unsigned uBytes;
Console Init( );
cls( );
szTestfile = "c:\\TestFile.txt";
hTestFile = CreateFile(szTestFile.GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
sprintf (szirdCreateFile; "TestLine"); //call this line "line 1"
WriteFile(hTestFile, szirdCreateFile, sizeof(szirdCreateFile)-1, &uBytes, 0); //"line 2"
sprintf (szirdCreateFile; "2ndTestLine"); //"line 3"
WriteFile(hTestFile, szirdCreateFile, sizeof(szirdCreateFile)-1, &uBytes, 0); //"line 4"
When I run the program, it's like the two lines mesh together on the same line and create some unintelligible characters. When lines 1 and 2 are commented out "2ndTestLine" appears in the file and when lines 3 and 4 are commented out "TestLine" appears in the file. My goal is to get "2ndTestLine" to appear on the line beneath "TestLine." PLEASE HELP!!!