运行时显示expression syntax in function main和其他3个错误
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Telephone
{
char number[200];
char name[20];
char fia[20];
char addrass[20];
char mail[20];
char telephone[20];
struct Telephone *next;
}student[50];
typedef struct Telephone TEL;
TEL *head=NULL;
void showmenu();
void Appenditem();
void print();
void Finditem1(); void Correct();
void Removeitem();
void Saveandfree();
void Open(); main()
{
char ch;
Open(); while(1)
{
showmenu(); scanf(" %c",&ch);
switch(ch)
{
case '1':Appenditem();
break;
case '2':print(); break;
case '3':Finditem1();
break;
case '4': Removeitem();
print();
break;
case '5': Correct();
break;
case '0':Saveandfree();
exit(0);
break;
default:
printf("选择错误!");
break;
}
}
}
void showmenu()
{
printf("\n*********************通讯录**********************\n");
printf("* \t1.录入信息 *\n");
printf("* \t2.输出信息 *\n");
printf("* \t3.按姓名查询 *\n");
printf("* \t4.删除信息 *\n");
printf("* \t5.修改信息 *\n");
printf("* \t0.保存并退出! *\n");
printf("*************************************************\n");
printf("\t请选择:\n");
}
void Appenditem()
{
TEL *p1=NULL,*p2=NULL;
p1=(TEL *)malloc(sizeof(TEL));
printf("输入编号:\n");
scanf("%s",p1->number);
printf("输入姓名:\n");
scanf("%s",p1->name);
printf("输入单位:\n");
scanf("%s",p1->fia);
printf("输入通讯地址:\n");
scanf("%s",p1->addrass);
printf("输入邮箱:\n");
scanf("%s",p1->mail);
printf("输入联系电话:\n");
scanf("%s",p1->telephone);
p1->next=NULL;
if(head==NULL)
{
head=(TEL *)malloc(sizeof(TEL));
head->next=p1;
}
else
{
for(p2=head;p2->next!=NULL;p2=p2->next);
p2->next=p1;
}
printf("此信息已添加!");
}
void print()
{
TEL *p=NULL;
if(head==NULL)
{
printf("此通讯录中无记录,请输入记录后在使用本功能!\n");
return;
}
printf("*******************通讯录*********************\n");
printf("编号\t姓名\t单位\t通信地址\t 邮箱\t联系电话\n");
for(p=head->next;p!=NULL;p=p->next)
printf("%s\t%s\t%s\t%s\t%s\t%s\n",p->number,p->name,p->fia,p->addrass,p->mail,p->telephone);
}
void Finditem1()
{
TEL *p;
char findname[20];
printf("请输入要查找的姓名:\n");
scanf("%s",findname);
printf("********************通讯录*********************\n");
printf("编号\t姓名\t单位\t通信地址\t 邮箱\t联系电话\n");
for(p=head->next;p!=NULL;p=p->next)
{
if(strcmp(p->name,findname)==0)
printf("%s\t%s\t%s\t%s\t%s\t%s\n",p->number,p->name,p->fia,p->addrass,p->mail,p->telephone);
}
}
void Correct()
{
TEL *p1(TEL *head);
{
struct Telephone *p1;
char name[20];
printf("输入要修改的人名:\n");
scanf("%s",name);
p1=head;
int flag=0;
while(p1!=NULL)
{
if(strcmp(p1->name,name)==0)
{
printf("输入新编号:\n");
scanf("%s",p1->number);
printf("输入新姓名:\n");
scanf("%s",p1->name);
printf("输入新单位:\n");
scanf("%s",p1->fia);
printf("输入新通讯地址:\n");
scanf("%s",p1->addrass);
printf("输入邮箱:\n");
scanf("%s",p1->mail);
printf("输入新联系电话:\n");
scanf("%s",p1->telephone);
flag=1;
}
p1=p1->next;
}
}
printf("修改完成");
}
void Removeitem()
{
char findname[20];
TEL *p=head,*pr=head;
printf("请输入要删除的姓名:\n");
scanf(" %s",findname);
if (head== NULL)
{
printf("无此结点!\n");
return;
}
while ((strcmp(p->name,findname)!=0 )&& p->next != NULL)
{
pr =p;
p =p->next;
}
if(strcmp(p->name,findname)==0)
{if(p==head)
head=p->next;
else
pr->next=p->next;
free(p);
}else
printf("没有要删除的对象\n");
printf("已删除");
}
void Saveandfree()
{
TEL *p=NULL;
FILE *fp;
char *Book="books.txt";
if(head==NULL)
{
printf("\n记录为空!\n");
return;
}
else
p=head->next;
if((fp=fopen(Book,"wb+"))==NULL)
{
printf("\n打不开文件!\n");
return;
}
while(p!=NULL) {
fwrite(p,sizeof(TEL),1,fp);
p=p->next;
}
printf("保存完毕!");
fclose(fp);
for(;head->next!=NULL;)
{
p=head->next;
head->next=head->next->next;
free(p);
}
free(head);
}
void Open()
{
FILE *fp;
TEL *p1=NULL,*p2=NULL,*temp=NULL;
if((fp=fopen("books.txt","rb+"))==NULL)
{
printf("\n*******************通讯录******************\n");
return;
}
head=(TEL *)malloc(sizeof(TEL));
head->next=NULL;
temp=p2=head;
while(! feof(fp)) {
p1=(TEL *)malloc(sizeof(TEL));
temp=p2;
p2->next=p1;
p2=p1;
fread(p1,sizeof(TEL),1,fp);
}
temp->next=NULL;
fclose(fp);