菜b向刚刚呢个写入文件的结构体中添加了一个创建功能。。。然后就全是错误了啊啊啊。我把我觉得错的地方标了一下
#include<stdio.h>struct student
{
char name[10];
char sex;
long int phone;
char adress[20];
long int QQ;
};
int main()
{FILE*fp;
int i;
struct student stu[20]={{"Lily",'W',111123,"apple road",56443256},
{"Bob",'M',657894,"banaba road",554511283},
{"Tom",'M',897523,"tower road",564432123},
{"Kity",'W',495821,"rain road",56458369},
{"Tony",'M',367498,"gold road",564454781},
{"Sed",'M',232599,"air road",294658715}};
fp=fopen("D:\\stl.txt","wb");
for(i=0;i<6;i++)
fprintf(fp,"%s\t %c\t %ld\t %s\t %ld",stu[i].name,stu[i].sex,stu[i].phone,stu[i].adress,stu[i].QQ);
fclose(fp);
[color=#FF0000]i=Creat(i);[/color]
return 0;
}
int Creat(int num)
{
FILE*fp
int j=num+1;
printf("请输入姓名(英文):");
scanf("%s",stu[j].name);
printf("请输入性别(m男,w女):");
scanf("%c",stu[j].sex);
printf("请输入电话:");
scanf("%ld",stu[j].phone);
printf("请输入地址(英文):");
scanf("%s",stu[j].adress);
printf("请输入QQ号:");
scanf("%ld",stu[j].QQ);
num++;
fp=fopen("D:\\stu.txt","wb");
fprintf(fp,"%s\t %c\t %ld\t %s\t %ld",stu[j].name,stu[j].sex,stu[j].phone,stu[j].adress,stu[j].QQ);
fclose(fp);
for (j=0;j<num;j++)
printf("%d\t %s\t %c\t %5d\t %s\t %5d\n",stu[i].count,stu[i].name,stu[i].sex,stu[i].phone,stu[i].adress,stu[i].QQ);
return(num)
}