怎么都找不出错误,可就是运行不起来
enter()和Listz()函数不可能有问题的啊,帮忙看看。
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
struct queue
{char data;
struct queue*next;
}*front,*rear;
void menu()
{puts("1 Enter");
puts("2 List");
}
void Enter()
{struct queue*p;
char ch;
front=(struct queue*)malloc(sizeof(struct queue));
front->data='\0';
front->next=NULL;
rear=front;
puts("please input rhe char one by one:");
scanf("%c",&ch);
getchar();
while(ch!='0')
{p=(struct queue*)malloc(sizeof(struct queue));
p->data=ch;
p->next=NULL;
rear->next=p;
rear=p;
scanf("%c",&ch);
getchar();
}
}
void List()
{struct queue*q;
q=front->next;
while(q!=NULL)
{printf("%c",q->data);
q=q->next;
}
}
void main()
{int num;
menu();
while(1)
{scanf("%d",&num);
switch(num)
{case 1:
clrscr();
Enter();
clrscr();
break;
case 2:
clrscr();
List();
getch();
clrscr();
break;
}
menu();
}
}