second commit

master
parent 48f57d9dc9
commit dcc4004495

@ -92,7 +92,38 @@ void search()
//ä¯ÀÀ
void look()
{
char c;
if((fp=fopen("user.txt","r"))==NULL) //打开文件user.txt
{
printf("读取信息失败!\n");
exit(0);
}
int m=0;
while(!feof(fp))
{
if(fread(&user[m],sizeof(struct user),1,fp)==1)
m++;
}
int i;
printf("姓名\t\t籍贯\t\t电话1\t\t电话2\t\t邮箱\n");
for(i=0;i<m;i++)
{
printf("%-8s\t",user[i].name);
printf("%-15s\t",user[i].place);
printf("%-15s\t",user[i].tel1);
printf("%-15s\t",user[i].tel2);
printf("%-20s\t",user[i].email);
printf("\n");
}
if(fclose(fp)) //关闭文件
{
printf("关闭文件失败!\n");
exit(0);
}
scanf("%c",&c);
printf("是否继续Y/N");
scanf("%c",&c);
if(c=='y'||c=='Y')
menu();
return;
}

Binary file not shown.
Loading…
Cancel
Save