切换错误重新声明' manu'如何解决这个问题?
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *nxtadd;
}*head=NULL,*temp,*temp1;
void insert_first()
{
if(head==NULL)
{
head=(struct node *)malloc(sizeof(struct node));
scanf("%d",&head->data);
head->nxtadd=NULL;
}
else
{
temp1=head;
while(temp1->nxtadd!=NULL)
{
temp=temp1->nxtadd;
}
}
}
void display()
{
if(head==NULL)
{
printf("No LINK LIST Crated , First Insert Record.");
}
else
{
temp1=head;
while(temp1!=NULL)
{
printf("%d",&head->data);
temp=temp1->nxtadd;
}
}
}
void delete_first()
{
if(head==NULL)
{
printf("No LINK-LIST Created, First insert record(s).");
}
else
{
temp=head;
head=head->nxtadd;
free(temp);
display();
}
}
void sub_manu_insert()
{
int a;
while(1)
{
printf("------------------------------------------------------------/n");
printf(" LINK LIST - Sub Manu. \n");
printf("------------------------------------------------------------/n");
printf("select Opration\n");
printf("------------------------------------------------------------/n");
printf("1). insert-first\n");
printf("2). insert-last\n");
printf("3). Exit\n");
printf("------------------------------------------------------------/n");
scanf("%d",&a);
switch(a)
{
case 1:
insert_first();
break;
case 2:
insert_last();
break;
case 3:
clrscr();
manu();
break;
default:
printf("Enter Proper Number..");
}
}
}
void sub_manu_delete()
{
int a;
while(1)
{
printf("------------------------------------------------------------/n");
printf(" LINK LIST - Sub Manu. \n");
printf("------------------------------------------------------------/n");
printf("select Opration\n");
printf("------------------------------------------------------------/n");
printf("1). Delete-first\n");
printf("2). Delete-last\n");
printf("3). Exit\n");
printf("------------------------------------------------------------/n");
scanf("%d",&a);
switch(a)
{
case 1:
delete_first();
break;
case 2:
delete_last();
break;
case 3:
clrscr();
manu();
break;
default:
printf("Enter Proper Number..");
}
}
}
void manu()
{
int a;
while(1)
{
printf("------------------------------------------------------------/n");
printf(" LINK LIST \n");
printf("------------------------------------------------------------/n");
printf("select Opration\n");
printf("------------------------------------------------------------/n");
printf("1). Insert New Record\n");
printf("2). Display Record\n");
printf("3). Delete Record\n");
printf("4). Exit\n");
printf("------------------------------------------------------------/n");
scanf("%d",&a);
switch(a)
{
case 1:
sub_manu_insert();
break;
case 2:
display();
break;
case 3:
sub_manu_delete();
break;
case 4:
sub_manu_update();
break;
case 5:
exit(0);
break;
default:
printf("Enter Proper Number...\n");
break;
}
}
}
void main()
{
clrscr();
manu();
getch();
}
答案 0 :(得分:1)
在C中,应该在使用函数之前声明或定义函数。否则,将为该函数创建一个默认声明,如果这与真实定义不匹配,您将收到错误。
所以在程序开头放一个函数声明:
void manu();