请问高手,这个程序有哪些问题
我今年大二了,这是我们数据结构的作业,要求是用链表定义结构体通讯录,输入删除,插入查找,输出,每次都要求返回主界面,下面是我自己写的程序,是照着教材写的,有错误,可能是我对于教材的理解还不太深,有没高手能指出我的错误,指点一下啊,大学不想空虚的度过。。#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void insert(struct note head);
void delet(struct note head,int i);
void get(struct note head);
void find(struct note head);
void exit(struct note head);
typedef int datatype;
struct note
{
char name[20];
long int num;
struct note *next;
};
int n;
struct note *input()
{
printf("please input information");
struct note *head;
struct note *p1,*p2;
n=0;
p1=p2=(note*)malloc(sizeof(note));
scanf("%s,%ld",p1->name[20],&p1->num);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)
head=p1;
else p2->next=p1;
p2=p1;
p1=(struct note*)malloc(sizeof(note));
scanf("%s,%ld",p1->name[20],&p1->num);
}
p2->next=NULL;
return (head);
}
void menu(struct note head)
{
int x;
int i;
printf("1-insert");
printf("2-delete");
printf("3-get");
printf("4-find");
printf("5-exit");
scanf("%d",&x);
if(x==1)
void insert(struct note head);
else if(x==2)
printf("please input i");
scanf("%d",&i);
delet(struct note head,int i);
else if(x==3)
get(struct note head);
else if(x==4)
find(struct note head);
else if(x==5)
exit(struct note head);
}
void insert(struct note head)
{
printf("please insert");
struct note *p3;
p3=(struct note*)malloc(sizeof(note));
scanf("%s,%ld",p3->name[20],&p3->num);
p3->next=head;
void menu();
}
void delet(struct note head,int i)
{
struct note *p=head;
struct note *s;
int j=0;
while(p->next!=NULL&&j<i)
{
p=p->next;
j++;
}
if(j==i)
s=p->next;
p->next=s->next;
else{
printf("wrong");
}
void menu();
}
void get(struct note head)
{
struct note *p=head;
struct note *s;
int j=0;
while(p->next!=NULL&&j<i)
{
p=p->next;
j++;
}
if(j==i)
s=p->next;
p->next=s->next;
else{
printf("wrong");
}
void menu();
}
void find(struct note head)
{
string str1[20];
scanf("%s",str1[20]);
struct note *p=head;
int i;
while(strcmp(p->name,str1!=0))
{
p=p->next;
}
printf("%s,%ld",p->name[20],&p->num);
void menu();
}
void exit(struct note head)
{
note *p=head;
while(p!=NULL)
{
printf("%s,%ld",p->name[20],&p->num);
p=p->next;
}
}
int main()
{
typedef struct note;
struct note *head;
head=input;
menu(head);
return 0;
}