建栈时出错
什么情况,帮忙找下错误#include <stdio.h>
#define MAXNUM 100
#define NIL 0
typedef int elemtype;
typedef struct
{
elemtype Stack[MAXNUM];
int Top;
}qstype;
void InitiateQStack(qstype *s)//初始化栈
{
s->Top=-1;
}
int PushQStack(qstype *s)//进栈
{
elemtype x;
if(s->Top>=MAXNUM-1) return 0;
else
{
scanf("%d",&x);
s->Stack[++(s->Top)]=x;
return 1;
}
}
elemtype PopQStack(qstype *s)//出栈
{
if(s->Top<0) return NIL;
else return s->Stack[(s->Top)--];
}
/*
elemtype GetTopQStack(qstype *s)
{
if(s->Top<0) return NIL;
else return s->Stack[s->Top];
}*/
int main()
{
qstype *p;
InitiateQStack(p);
if(PushQStack(p))
{
printf("%d\n",PopQStack(p));
}
getchar();
return 0;
}