Z
Zach
I am trying to use fseek to move file pointer position to the very
beginning of the file and write "<HTML>" and then move to the very end
and write "</HTML>" but instead it is writing the "<HTML>" at the end
of the first line of the file instead of at the beginning of the first
line. From everything I've read this *should* work. Hope someone can
tell me what's wrong.
first line of "test.log" is:
This is line 1 of test file.
So after I run the code it produces:
This is line 1 of test file.<HTML>
</HTML>
Code:
FILE *fp;
fp = fopen("test.log","a+");
fseek(fp, 0, SEEK_SET);
fprintf(fp,"<HTML>\n");
fseek (fp , 0 , SEEK_END);
fprintf(fp,"</HTML>\n");
fclose(fp);
Zach
beginning of the file and write "<HTML>" and then move to the very end
and write "</HTML>" but instead it is writing the "<HTML>" at the end
of the first line of the file instead of at the beginning of the first
line. From everything I've read this *should* work. Hope someone can
tell me what's wrong.
first line of "test.log" is:
This is line 1 of test file.
So after I run the code it produces:
This is line 1 of test file.<HTML>
</HTML>
Code:
FILE *fp;
fp = fopen("test.log","a+");
fseek(fp, 0, SEEK_SET);
fprintf(fp,"<HTML>\n");
fseek (fp , 0 , SEEK_END);
fprintf(fp,"</HTML>\n");
fclose(fp);
Zach