Been working on this for a whole day now. I need to write text at a particular point in a file.

CODE:
Code:
/* fseek example */
#include <stdio.h>

int main ()
{
FILE * pFile;
pFile = fopen ( "myfile.txt" , "w" );
fputs ( "This is an apple." , pFile );
fseek ( pFile , 9 , SEEK_SET );
fputs ( " sam" , pFile );
fclose ( pFile );
return 0;
}
OUTPUT:

This is an apple. sam

SHOULD BE:

This is a sample.


Could it be my compiler? I just have a crappy one that I downloaded online somewhere.


fflush(pFile)

after my first fputs() doesn't work either. =(

Last edited by shabbir; 4Dec2007 at 11:39.. Reason: Code block