I do not understand why the following code can create the aaa file, but cannot write '1' (the buffer value) into the aaa file.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
int b;
int buf;
FILE *fp;
buf = 1;
a = 5;
b = 6;
fp = fopen("c:\\aaa.txt","wb");
fwrite(&buf, sizeof(int),1,fp);
return 0;
}
call fclose(fp) or fflush(fp) to make sure content of file buffer gets flushed to the file.
Add fclose(fp); before returning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With