求教大虾,程序哪错了
输入朋友信息,并将其写入文件#include<stdio.h>
#include<stdlib.h>
struct friends_list{
int num;
char name[20];
int age;
char adrr[20];
};
int main(void)
{
FILE *ptr;
struct friends_list friends[10], sdu, *pf,*pd;
long size=sizeof(struct friends_list);
int count=0;
pf=friends;
pd=&sdu;
printf("Enter imformation:\n");
do{
printf("num.name.age.adrr\n");
scanf("%d.%s.%d.%s",&pf->num,pf->name,&pf->age,pf->adrr);
pf++;
count++;
}while((pf-1)->num!=0);
pf=friends;
if((ptr=fopen("f1.txt","w"))==NULL){
printf("File open error!\n");
exit(0);
}
fwrite(pf,size,count,ptr);
rewind(ptr);
if(!feof(ptr)){
fread(pd,size,1,ptr);
printf("%d-%s-%d-%s",pd->num,pd->name,pd->age,pd->adrr);
}
fclose(ptr);
return 0;
}