inking
Cpp1.obj : error LNK2001: unresolved external symbol "void __cdecl ModifyInformation(struct student * const,int)" (?ModifyInformation@@YAXQAUstudent@@H@Z)
Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
void modifyInformation(STUDENT stu[],int n)
{
int i,j,k,item,m=0,find=0;
long s1;
FILE *fp;
printf("请输入要修改的学生学号:");
scanf("%ld",&s1);
fp=fopen("E:\demo.txt","r");
if(fp==NULL)
{
printf("打开文件失败,请重试!");
getch();
fclose(fp);
exit(0);
}
while(!feof(fp))//扫描文件
{
fscanf(fp,"%ld",&stu[m].studentID);
m++;
}
for(i=0;i<n;i++)
{
if(stu[i].studentID==s1)
{
j=i;
find=1;
printf("1---修改姓名\n");
printf("2---修改性别\n");
printf("3---修改地址\n");
printf("4---修改电话\n");
printf("5---退出程序\n");
printf("请输入你的选择:\n");
scanf("%d",&item);
switch(item)
{
case 1:
printf("请输入新的姓名:\n");
scanf("%s",&stu[j].studentName);
break;
case 2:
printf("请输入新的性别:\n");
scanf("%c",&stu[j].studentSex);
break;
case 3:
printf("请输入新的地址:\n");
scanf("%s",&stu[j].address[j][20]);
break;
case 4:
printf("请输入新的电话:\n");
scanf("%ld",&stu[j].phonenumber);
break;
case 5:
printf("End of the program!");
exit(0);
}
}
}
fclose(fp);
if(find==0)
{
printf("没有找到要修改的学生记录,请按任意键退出!");
getch();
}
else
{
fp=fopen("E:\\demo.txt","w");
for(k=0;k<n;k++)
{
fprintf(fp,"%ld %s %c %s %ld",stu[i].studentID,stu[i].studentName,stu[i].studentSex,
stu[i].address[i][20],stu[i].phonenumber);//更新数据
}
fclose(fp);
printf("录入学生信息成功,请按任意键返回\n");
getch();
}
}
typedef struct student
{
long studentID;
char studentName[10];
char studentSex;
char address[N][20];
long phonenumber;
}STUDENT;