I am trying to use this code, except instead of overwriting the file I want to just append it. However, when I use the mode "a" or "a+", the fseek seems to not work. Instead of writing to the file "This is C Programming Langauge", as expected, it writes "This is tutorialspoint.com C Programming Langauge". What can I do to not overwrite the file?
I want to be able to open a file with text already in it, set the file pointer to a certain point, and write text to that point without overwritign anything else in the file.
int main ()
{
FILE *fp;
fp = fopen("file.txt","w+");
fputs("This is tutorialspoint.com", fp);
fseek( fp, 7, SEEK_SET );
fputs(" C Programming Langauge", fp);
fclose(fp);
return(0);
}