Changing one byte in a file in C
c
Solution
#include "stdio.h"
int main(void)
{
FILE* f = fopen("so-data.dat", "r+b"); // Error checking omitted
fseek(f, 5, SEEK_SET);
fwrite("x", 1, 1, f);
fclose(f);
}
Problem
I have a file stream open and ready. How do I access and change a single Byte in the stream such that the change is reflected on the file? Any suggestions?