老出现struct Info *()' differs in levels of indirection from 'int ()'
#include <stdio.h>#include <malloc.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
enum Sex{male,female}; /*性别*/
enum Education{high,junior,college,master,doctor}; /*学历*/
struct Date /*日期*/
{
int year;
int month;
int day;
};
typedef struct Info
{
char num[10]; /*职工号*/
char name[15]; /*姓名*/
enum Sex sex; /*性别*/
struct Date birthday; /*出生年月*/
enum Education education; /*学历*/
char duty[15]; /*职务*/
double wage; /*工资*/
char addr[30]; /*地址*/
char phone[15]; /*电话*/
struct Info * next;
}Info;
struct Info* LinkList_creat();
struct Info* LinkList_insert(struct Info *head);
void LinkList_display(struct Info *head);
void LinkList_delete(struct Info *head);
void LinkList_find(struct Info *head);
struct Info* LinkList_change(struct Info *head);
int main()
{
char choose;
struct Info *head;
head=NULL;
while(1)
{
printf("\n**************** Command Menu ****************\n");
printf("**************** 1:信息录入 ****************\n");
printf("**************** 2:插入信息 ****************\n");
printf("**************** 3:信息删除 ****************\n");
printf("**************** 4:信息浏览 ****************\n");
printf("**************** 5:信息查询 ****************\n");
printf("**************** 6:信息修改 ****************\n");
printf("**************** 7:退 出 ****************\n\n");
printf("**************** ps:本系统使用无头链表 系统bug:num必须互斥 以num ID 优先操作****************\n");
choose=getch();
switch(choose)
{
case '1':
{
if(head!=NULL)
{
printf("A linklist exists already!\n\n");
break;
}
else
{ head=LinkList_create();
break; }
}
case '2':
{
if(head==NULL)
{
printf("No list has been created!Choose again!\n\n");
break;
}
else
head=LinkList_insert(head);
break;
}
case '3':
{
if(head==NULL)
{
printf("No list has been created!Choose again!\n\n");
break;
}
else
LinkList_delete(head);
break;
}
case '4':
{
if(head==NULL)
{
printf("No list has been created!Choose again!\n\n");
break;
}
else
LinkList_display(head);
break;
}
case '5':
{
if(head==NULL)
{
printf("No list has been created!Choose again!\n\n");
break;
}
else
LinkList_find(head);
break;
}
case '6':
{
if(head==NULL)
{
printf("No list has been created!Choose again!\n\n");
break;
}
else
head=LinkList_change(head);
break;
}
case '7':
{
printf("Are you sure to exit?N to cancel or the program will exit.\n");
if(getch()=='N')
{
printf("Exit request cancelled!\n");
break;
}
else
{
printf("Program end!\n");
return 0;
}
}
default:
printf("Warning!Error choose!\n\n");
break;
}
}
free(head);
head=NULL;
return 0;
}
struct Info* LinkList_create()
{
int n,i;
struct Info* head=NULL;
struct Info* pf=NULL;
struct Info* pb=NULL;
printf("How many workers do you want to creat?\n");
scanf("%d",&n);
for(i=0;i<n;i++);
{
printf("Input the Infomation about this workers.\n");
pb=(struct Info*)malloc(sizeof(struct Info*));
printf("\num:"); scanf("%d",&pb->num);
printf("\name:"); scanf("%d",&pb->name);
printf("\sex(male or female):"); scanf("%d",&pb->sex);
printf("\birthday(yyyy/mm/dd):"); scanf("%d/%d/%d",&pb->birthday.year,&pb->birthday.month,&pb->birthday.day);
printf("\education:"); scanf("%d",&pb->education);
printf("\duty:"); scanf("%d",&pb->duty);
printf("\wage"); scanf("%d",&pb->wage);
printf("\address"); scanf("%d",&pb->addr);
printf("\telphone"); scanf("%d",&pb->phone);
if(i==0)
{
head=pb;
pf=pb;
}
else
{
pf->next=pb;
pf=pb;
}
}
pb->next=NULL;
return head;
}
struct Info* LinkList_insert(struct Info *head)
{
struct Info *newInfo;
struct Info *pf=head;
struct Info *pb=head;
newInfo=(struct Info*)malloc(sizeof(struct Info));
printf("\num:"); scanf("%d",&newInfo->num);
printf("\name:"); scanf("%d",&newInfo->name);
printf("\sex(male or female):"); scanf("%d",&newInfo->sex);
printf("\birthday(yyyy/mm/dd):"); scanf("%d/%d/%d",&newInfo->birthday.year,&newInfo->birthday.month,&newInfo->birthday.day);
printf("\education:"); scanf("%d",&newInfo->education);
printf("\duty:"); scanf("%d",&newInfo->duty);
printf("\wage"); scanf("%d",&newInfo->wage);
printf("\address"); scanf("%d",&newInfo->addr);
printf("\telphone"); scanf("%d",&newInfo->phone);
while(pb->num<=newInfo->num)
{
pf=pb;
pb=pb->next;
if(pb==NULL)
break;
}
pf->next=newInfo;
newInfo->next=pb;
return head;
}
void LinkList_display(struct Info* head)
{
do
{
printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
}while(head=head->next);
}
void linklist_delete(struct Info* head)
{
char num[10];
struct Info* pf;
struct Info* pb;
pf=head;
pb=head;
printf("Which workers do you want to delete?");
printf("Input the num:");
scanf("%d",&num);
while(pb->num!=num)
{
pf=pb;
pb=pb->next;
if(pb==NULL)
{
printf("The inputed num doesn't exist!\n");
return ;
}
}
pf->next=pb->next;
printf("delete OK!\n");
}
void LinkList_find(struct Info* head)
{
char num[10];
printf("Input the num to find ...\n");
scanf("%d",&num);
while(head->num!=num)
{
head=head->next;
if(head==NULL)
{
printf("the inputed num dosen't exist!");
return ;
}
}
if(head->num==num)
printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
}
struct Info* LinkList_change(struct Info* head)
{
char num[10];
struct Info* pf;
struct Info* pb;
pf=head;
pb=head;
printf("Which workers do you want to change?");
printf("Input the num:");
scanf("%d",&num);
while(pb->num!=num)
{
printf("Infomation:%d %d %d %d %d %d %d %d %d %d %d\n",head->num,head->name,head->sex,head->birthday.year,head->birthday.month,head->birthday.day,head->education,head->duty,head->wage,head->addr,head->phone);
pb=(struct Info*)malloc(sizeof(struct Info*));
printf("\num:"); scanf("%d",&pb->num);
printf("\name:"); scanf("%d",&pb->name);
printf("\sex(male or female):"); scanf("%d",&pb->sex);
printf("\birthday(yyyy/mm/dd):"); scanf("%d/%d/%d",&pb->birthday.year,&pb->birthday.month,&pb->birthday.day);
printf("\education:"); scanf("%d",&pb->education);
printf("\duty:"); scanf("%d",&pb->duty);
printf("\wage"); scanf("%d",&pb->wage);
printf("\address"); scanf("%d",&pb->addr);
printf("\telphone"); scanf("%d",&pb->phone);
if(pb==NULL)
{
printf("The inputed num doesn't exist!\n");
return 1;
}
}
printf("change OK!\n");
return head;
}