顺序栈的基本操作的基础


#include
#include
#define max 6
typedef struct Stack
{
    int arr[max];
    int val;
    int top;
}stack;
stack *pst;
int isfull(stack *p)
{
    if(p->top==max-1)
    return 0;
    else
    return 1;
}
void push(stack *p,int data)
{
    if(isfull(p))
    {
        p->arr[++(p->top)]=data;
    }
}
int isempty(stack *p)
{
    if(p->top==-1)
    return 1;
    else
    return 0;
}
int pop(stack *p)
{
    if(isempty(p))
    {
        return (p->arr[p->top--]);
    }
}
int main()
{
    pst->top=-1;
    int num,r;
    int i;
    for(i=0;iscanf("%d",&num);
        push(pst,num);
        r=pop(pst);
        printf("%d ",r);
    }    
}

顺序栈的初始、判满、入栈、判空、出栈、打印
为什么 这样写是错的,无结果

第42行 pts是个指针,需要先malloc空间,不然地址非法访问了