I want to change one value of a file, but the follow code doesn’t work at all. It works properly when i remove the if statement.
Code follows:
#include <stdio.h>
int main()
{
int b;
FILE *fp;
fp=fopen("new", "r+");
fseek(fp, 0x30, 0);
b = fgetc(fp);
if(b == 0x63)
fputc(0x64, fp);
fclose(fp);
return 0;
}
file “new”:
c111111111c1111111111111111111111111111111111111c1111111111111111111
Is there some details that I don’t know?
You’ve written one past
bif it is0x63, becausefgetcadvances the file stream: