Hello
I am trying to write some data to a certain position in a file, but cannot get it to work
I want to write "XX" to position 6 of a specified file, but the data is just being written to the end of file.
see below
#include<stdlib.h>
main()
{
FILE *stream;
char buffer[20]="XX";
fpos_t file_pos;
stream = fopen("ste.txt", "a+" );
fseek(stream, 10, SEEK_SET );
fgetpos(stream, &file_pos );
fsetpos(stream, &file_pos );
printf("File Pos :%ld\n", file_pos );
fwrite(&buffer,1,file_pos,stream );
fclose(fp);
exit(1);
}