错误:“fwrite”的参数 1 的类型不兼容 /usr/include/stdio.h:688: 注意:应为“const void * restrict”,但参数类型为“struct oseba” make: *** [E1041080] 错误 1
struct oseba{
char baza[100];
int telefonska;
char ime[10];
char priimek[20];
int dan;
int mesec;
int leto;
};
children ,我需要帮助!怎么了?
------------------------写---------------- ----
FILE*file=fopen("fhfh.dat","wb");
if(file!=NULL)
{ fwrite(oseba1,sizeof(struct oseba),1,file);
fclose(file);
}
最佳答案
您需要将一个指针 传递给该结构。也就是说,
fwrite(&oseba1, sizeof(struct oseba), 1, file);
但是请注意,通过将structs
写入二进制文件,很有可能文件因此保存will not be portable ,例如您甚至不能在程序的 32 位和 64 位编译之间或从平台到另一个平台共享它。
关于c - 使用 fwrite() 将结构写入文件错误 688,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35925995/