RT
运行了一下,显示有一错误,"Expression syntax in function save"
#include<stdio.h>
#define SIZE 5
struct person_type
{char name[10];
char tel[15];
char addr[50];
}
person[SIZE];
void save()
{FILE *fp1,*fp2;
int i;
if((fp1=fopen("person_list","wb"))==NULL)
{
printf("cannot open file\n");
return;
}
for(i=0;i<SIZE;i++)
if(fwrite(&person[i],sizeof(struct person_type),1,fp1)!=1)
printf("file write error\n");
fclose(fp1);
void main()
{int i;
for(i=0;i<SIZE;i++)
scanf("%s%s%s",person[i].name,&person[i].tel,&person[i].addr);
save();
fp2=fopen("person_list","rb");
{fread(&person[i],sizeof(struct person_type),1,fp2);
printf("%-10s%-15s%-50s\n",person[i].name,person[i].tel,person[i].addr);
}}
fclose(fp2);
}