职工信息管理系统(存储方式为链表),请大神帮忙找下错误
#include<stdio.h>#include<stdlib.h>
#include<string.h>
struct employee{
int num;
char name[10];
int age;
double salary;
struct employee *next;
}
void new_employee(struct employee *head, struct employee s1 );
void search_employee (struct employee *head, int num);
void update_employee (struct employee *head, int num,double salary);
void delete_employee (struct employee *head, int num);
void output_employee (struct employee *head);
int main()
{
struct employee *head;
int choice,num,age;
char name[10];
double salary;
int size=sizeof(struct employee);
printf("******欢迎进入职工信息管理系统******\n");
do{
printf("1:new 2:search 3:update 4:delete 5:output\n");
scanf("%d",&choice);
switch(choice){
case 1:
printf("输入工号、名字、年龄、工资\n");
scanf("%d%s%d%lf",&s1.num,s1.name,&s1.age,&s1.salary);
head=new_emlpoyee(head,s1);break;
case 2:
printf("输入您要查找的职工工号:\n");
scanf("%d",&num);
head=search_employee(head,num);
break;
case 3:
printf("输入您要修改的职工的工号:\n");
scanf("%d",&num);
printf("输入错误的工资信息:\n");
scanf("lf",&salary);
head=update_employee(head,num,salary);
break;
case 4:
printf("输入您要删除的职工工号:\n");
scanf("%d",&num);
head=delete_employee(head,num);
case 5:
printf("输出职工信息\n");
head=output_employee(head);
break;
}
}while(choice!=0);
return 0;
}
void new_employee(struct employee *head, struct employee s1 ){
struct employee *p,*tail,*head;
head=NULL;
int size=sizeof(struct employee);
while(num!=0){
p=(struct employee *)malloc(size);
p->num=num;
p->age=age;
p->salary=salary;
strcpy(p->name,name);
p->next=head;
head=p;
scanf("%d%s%d%lf",&s1.num,s1.name,&s1.age,&s1.salary);
}
}
void search_employee (struct employee *head, int num){
struct employee *p;
for(p=head;p!=NULL;p=p->next){
if(num==p->num)
printf("%d%s%d%lf",p->num,p->name,p->age,p->salary);
}
}
void update_employee (struct employee *head, int num,double salary){
struct employee *p;
double s;
for(p=head;p!=NULL;p=p->next){
if(p->num==num){
scanf("lf",&s);
p->salary=s;
}
}
}
void delete_employee (struct employee *head, int num){
struct employee *p1,*p2;
while(head!=NULL&&head->num==num){
p2=head;
head=head->next;
free(p2);
}
if(head==NULL)
return;
p1=head;
p2=head->next;
while(p2!=NULL){
if(p2->num==num){
p1->next=p1->next;
free(p2);
}
else
p1=p2;
p2=p1->next;
}
}
void output_employee (struct employee *head){
struct employee *p;
if(head==NULL){
printf("\nNo Records\n");
return;
}
for(p=head;p!=NULL;p=p->next)
printf("%d\t%s\t%d\t%g\n",p->num,p->name,p->age,p->salary);
}