我编的一个管理系统不知道怎么改错误,请高手指教
#include"stdio.h"#include"string.h"
#define EMPLOYEEMAX 100
struct employeeinfo
{
char name[20];
char sex[10];
}
FILE *infofile=NULL;
char filename='c:\\information'
void showmenu();
void inputinfo(struct employeeifo *);
void modinfo(strcu employeeinfo *);
void aboutinfo(struct employeeinfo *);
void allabout(struct employeeinfo *);
void delinfo(struct employeeinfo *);
int main(void)
{
struct employeeinfo employeemax[EMPLOYEEMAX];
struct employeeinfo *p_employee;
p_employee=employeemax;
int in;
do
{
clrscr();
showmenu();
switch(in)
{
scanf("%d",&in);
case 1:inputinfo(p_employee);break;
case 2:modinfo(p_employee);break;
case 3:aboutinfo(p_employee);break;
case 4:allabout(p_employee);break;
case 5:delinfo(p_employee);break;
case 6:break;
default :printf("wrong choosing,please choose again");
getch();
clrscr();
break;
}
}while(in!=6);
getch();
clrscr();
return 0;
}
void showmenu(void)
{
printf("\n\n\n\n");
printf("\t\t _____________________________________ \n");
printf("\t\t | employee information manage |\n");
printf("\t\t |_____________________________________|\n");
printf("\t\t | 1 : input information |\n");
printf("\t\t | 2 : modify information |\n");
printf("\t\t | 3 : refer information |\n");
printf("\t\t | 4 : look-through information |\n");
printf("\t\t | 5 : delete information |\n");
printf("\t\t | 6 : get out sys |\n");
printf("\t\t |_____________________________________|\n");
printf("\t\t\t please putin right choise");
}
void input(struct employeeinfo *p_employee);
{
int count=0;
char ch;
clrscr();
if((infofile=fopen(filename,"a+b"))==NULL)
{
printf("file wrong");
getch();
exit(1);
}
rewind(infofile);
while(count<EMPLOYEEMAX)
{
printf("\nname");
gets(p_employee[count].name);
printf("\nsex");
gets(p_employee[count].sex);
fwrite(&p_employee[count++].name,sizeof(struct employeeinfo),1,infofile);
printf("get in next?(y/n)");
ch==getch();
if(ch=='y'||ch=='Y')
{
clrscr();
printf("please get in information");
continue;
}
else
{
printf("get over ,back!");
fclose(infofile);
getch();
clrscr();
return ;
}
}
return ;
}
void aboutinfo(struct employeeinfo *p_employee)
{
int i,count=0;
char ch;
char*temp=NULL;
clrscr();
if((infofile=fopen(filename,"rb"))==NULL)
{
printf("fail to open file,please cheack");
getch();
return ;
}
rewind(infofile);
for(count=0;fread(&p_employee,sizeof(struct employeeinfo),1,infofile)==1,count++)
{continue;}
fclose(infofile);
if(count==0)
{
printf("did not find information ,please cheack right");
getch();
clrscr();
return ;
}
temp=(char *)malloc(20*sizeof(char));
printf("please input name you want to find\n");
while(gets(temp)!=NULL&&temp[0]!='\0')
{
for(i=0;i<count;i++)
{
if(!strcmp(temp,p_employee[i].name))
{
clrscr();
printf("the information is:");
printf("\n name :p_employee[i].name");
printf("\n sex :p_employee[i].sex");
break;
}
}
free(temp);
printf("if you want to search next?(y/n)");
ch=getch();
if(ch=='y'||ch=='Y')
{
clrscr();
temp=(char *)malloc(20*(char))
printf("please inpur the name :\n");
continue;
}
else
{
printf("search over get back by any key!");
getch();
clrscr();
return ;
}
}
free(temp);
printf("get back by any key");
getch();
clrscr;
}
void allabout(struct employeeinfo *p_employee)
{
int i,count;
clrscr();
if((infofile=fopen(filename,"rb"))=NULL)
{
printff("fail to open file");
getch();
exit(1);
}
rewind(infofile);
for(count=0;fread(&p_employeeinfo[count],sizeof(struct employeeinfo),1,infofile)==1;count++)continue;
fclose(infofile);
if(!count)
{
printf("can not get data");
getch();
clrscr();
return ;
}
printf("the information is:\n");
for(i=0;i<count;i++)
{
printf("name :%s",p_employeeinfo[i].name);
printf("sex : %s",p_employeeinfo[i].sex);
printf("please get any key to look next information");
getch();
clrscr();
}
getch();
clrscr();
return ;
}
void delinfo(struct p_employeeinfo *p_employee)
{
int i,count;
char ch;
char *temp=NULL;
clrscr();
if((infofile=fopen(filename,"rb"))==NULL)
{
printf("fail to open file");
getch();
exit(1);
}
rewind(infofile);
for(count=0;fread(&p_employeeinfo[count],sizeof(struct employeeinfo),1,infofile)==1;count++)continue;
fclose(infofile);
if(!count)
{
printf("can not get data");
getch();
return ;
}
temp=(char *)malloc(20*sizeof(char));
printf("please getin the name :");
while(gets(temp)!==NULL&&temp!='\0')
{
for(i=0;i<count;i++)
{
if(!strcmp(temp,p_employeeinfo[i].name))
{
clrscr();
printf("Do you want to delete this?(y/n)");
if(ch=='n'||ch=='N')
{
free(temp);
clrscr();
printf("get back by ane key ");
getch();
clrscr();
return ;
}
for(i=0;i<count;i++)p_employee[i]=p_employee[i+1];
count--;
if((infofile=fopen(filename,"w+b"))==NULL)
{
printf("fail to open the file");
free(temp);
getch();
exit(1);
}
for(i=0;i<count;i++)if(fwrite(&p_employee[i],sizeof(struct employeeinfo),1,infofile)!=1)break;
free(temp);
clrscr();
printf("do you want to delete next one?(y/n)");
ch=getch();
if(ch=='n'||ch=='N')
{
fclose(infofile);
clrscr();
return ;
}
else
{
clrscr();
temp=(char *)malloc(20*sizeof(char));
printf("input name:");
break;
}
}
}
printf("can not find %s ,do you want to input again?(y/n)",temp);
getch();
if(ch=='Y'||ch=='y')
{
free(temp);
temp=(char *)malloc(20*sizeof(char));
clrscr();
printf("please get in the name :");
continue ;
}
else
{
free(temp);
clrscr();
return ;
}
}
free(temp);
getch();
clrscr();
}
void modinfo(strcu employeeinfo *p_employee)
{
int count,i,n;
char *temp;
char *new;
clrscr();
if((infofile=fopen(filename,"rb"))==NULL)
{
printf("fail to open the file");
getch();
exit(1);
}
rewind(infofile)
for(count=0;fread(&p_employee[count],sizeof(struct employeeinfo),1,infofile)==1;count++)continue;
fclose(infofile);
temp=(char *)malloc(20*sizeof(char));
new=(char *)malloc(20*sizeof(char));
printf("please input the name you want to change");
gets(temp);
for(i=0;i<count&&temp!=NULL&&temp!='\0';count++)
{
if(!strcmp(temp,p_employee[i].name))printf("1:%s 2:%s",p_employee[i].name,p_employee[i].sex);
}
printf("get out by "0"");
printf("chose what you want to change:\n ");
switch(n)
{
scanf("%d",&n);
case 1:
{
printf("\nplease get in new information\n");
gets(new);
strcop(p_enployee[i].name,new);
break;
}
case 2:
{
printf("please get in new information:\n")
gets(new);
strcop(p_emlopyee[i].sex,new);
break;
}
case 0:break;
default :printf("wrong choise")
getch();
clrscr();
break;
}
free(temp);
free(new);
infofile=fopen(filename,"w+b");
for(i=0;i<count;i++)
{
if(fwrite(&p_employee[i],sizeof(struct employeeinfo),1,infofile)==1)
coutinue;
else
{
fclose(infofile);
printf("fail to change information");
getch();
clrscr();
return ;
}
}
fclose(infofile);
return ;
}