一个顺序栈的问题.
程序代码:#include "stdio.h"
#include "stdlib.h"
#define Stack_size 50
#define TRUE 1
#define FALSE 0
typedef struct
{
int elem[Stack_size];
int top;
}Stack;
void InitStack(Stack *s)
{
s->top=-1;
}
int Push(Stack *s,int n)
{
if(s->top==Stack_size-1)
return FALSE;
else
{
s->elem[s->top]=n;
s->top++;
}
return TRUE;
}
int Pop(Stack *s,int *x)
{
if(s->top==-1)
return FALSE;
else
{
*x=s->elem[s->top];
s->top--;
}
return TRUE;
}
int main()
{
Stack *s;
int n,t,i=1,*p;
printf("DO You want to Creat a Stack ?(1[YES]/2[NO])");
scanf("%d",&t);
switch(t)
{
case 1 :
InitStack(s); //好像是这里出问题了,一运行就出现遇到问题需要关闭的错误.
printf("Input 0 Stop creat\n");
while(i<Stack_size)
{
printf("Please Input %d push :",i);
scanf("%d",&n);
if(Push(s,n))
i++;
else
break;
}
while(s->top!=-1)
{
printf("%4d",s->elem[s->top]);
s->top--;
}break;
case 2:
break;
}
return 0;
}请大家看看,那里出错了,











