#include <stdio.h>
struct struct_type
{
int d;
};
int main()
{
struct struct_type *cust;
cust->d=13;
FILE* fp;
fp = fopen("path to file", "wb+");
or,
fp = fopen("path to file", "w+");
fwrite(cust, sizeof(struct struct_type), 1, fp);
fclose(fp);
return 0;
}
預計輸出FWRITE寫入垃圾值到文件
寫入文件但是越來越垃圾的價值。
是由於這樣的話,但數據是相同的我是否使用W +或WB + +1的答案 – user1502952
'w'模式截斷文件長度爲零,或者創建文本文件寫作。 'wb'模式截斷文件爲零長度或創建二進制文件進行寫入。字符'b'不起作用,但允許符合ISO C標準。見[fopen](http://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html)和[這裏也是](http://www.manpagez.com/man/3/fopen/) – Gangadhar