学习文件二进制输入输出时,不能将对应数据归零
编译时,给出了一个错误提醒:error: incompatible types in assignment of char' to
char[10]'
#include<stdio.h>
typedef struct student
{
char name[10];
int age;
int score;
}STD;
int main()
{
FILE *fp;
int i;
STD std[10];
//输入数据到文件
fp=fopen("C:\\Users\\123\\Desktop\\123.txt","wb");
if(fp==NULL){
printf("open file failed.\n");
return 0;
}
fp=fopen("C:\\Users\\123\\Desktop\\123.txt","wb");
printf("输入把。\n");
scanf("%d",&i);
scanf("%s %d %d",std[i].name,&std[i].age,&std[i].score);
fwrite(std,sizeof(STD),1,fp);
//尝试将已经输入的数据改变
scanf("%d",&i);
std[i].name='0';//出现错误
std[i].age=0;
std[i].score=0;
fwrite(std,sizeof(STD),1,fp);
//输出验证是否数据已归零
fp=fopen("E;/dasheng","rb");
fread(std,sizeof(STD),4,fp);
printf("%s %d %d",std[i].name,std[i].age,std[i].score);
printf("\n");
fclose(fp);
return 0;
}
运行不了,出现error: incompatible types in assignment of char' to
char[10]',希望运行后的结果都是0
试过了将std[i].name=等于‘0’,0,NULL都没用