你使用栈时SeqStack *S;没有指向任何存储单元。事实上,S=NULL(因为是全局变量,自动设为0),因此对其成员变量的引用(如S->base = (SElemType*) malloc (STACK_INIT_SIZE * sizeof(SElemType));)是错误的
即将
typedef struct {
SElemType *base;
SElemType *top;
int stacksize;
} SeqStack;
SeqStack *S;//本句改为 SeqStack *S=(SeqStack *S)malloc(sizeof(SeqStack));即可
或改为SeqStack Q,*S=&Q;
或在int InitStack (SeqStack *S )中更改:更改为int InitStack (SeqStack *&S ){S=(SeqStack *S)malloc(sizeof(SeqStack));
欢迎继续提问!