updating a binary file without overwriting it -> C
I am trying to update a binary file that has inside some of these structures:
typedef struct _test{
char question[100];
char answer[100];
}test;
At some point, I want to update one of the answers that is kept inside of a file to another answer (writing back again the answer to the file), still, ev开发者_开发技巧erytime I update the file it will erase everything and write only the new test structure (tried in fopen with modes wb, wb+ and even wa+ and settinng the cursor with fseek but no luck).
How can I edit the file so it doesn't wipe the entire file?
Use fopen("myfile.txt", "r+b")
.
精彩评论