FILE* f = fopen("rajat", "w");
fputs("sometext", f);
fseek(f, 6, SEEK_SET);
fputs("is a", f);
fclose(f);
Successfully returns: "someteis a"
But
FILE* f = fopen("rajat", "a");
fputs("sometext", f);
fseek(f, 6, SEEK_SET);
fputs("is a", f);
fclose(f);
Does not work. Returns "sometextis a"
Any ideas why? What is the solution to this, so that the second code outputs exactly like the first?
"w+"
for the first one? Otherwise the file is destroyed and recreated. – Goldofpleasure