主函数中有不能达到的代码?

来源:百度知道 编辑:UC知道 时间:2024/05/26 19:40:28
#include<stdio.h>
#define MAX 20
#define TURE 1
#define FALSE 0
#define ERROR 0
#define OK 1
typedef struct
{ int data[MAX];
int top;
}SqStack;
IntiStack(SqStack *s);
int StackEmpty (SqStack s);
int Push (SqStack *s, int e);
int Pop (SqStack *s, int *e);
int GetTop(SqStack s, int *e);
char menu();
int main()
{ SqStack L;
int x,flag=1,n,k;
char ch;
IntiStack(&L);
StackEmpty(L);
do{ ch=menu(); clrscr();
switch (ch)
{ case '1': printf("please input a number to push:");
scanf("%d",&x);
break;
Push(&L,x); getch(); break;
case '2': Pop(&L,&n);
printf("the number to pop is: %d.",n); break;
case '3': GetTop(L,&k);
printf("the top number is:

你的程序需要修改以下:
①IntiStack(SqStack *s)
{s->top=-1;
}
这个函数,函数名前要应该加上void,表示无返回类型
另外在11行中的此函数声明处IntiStack(SqStack *s);前面也要加上void
②在主函数的最后一行要加上 return 0;因为你的主函数是int返回类型的(int main())