顺序栈匹配括号问题
C语言,提示在第十四行出现invalid use of void expression,并且有很多警告
#include <stdio.h>
#include <malloc.h>
#define MAXSIZE 100
typedef char SElemType; // 定义栈元素类型
typedef int Status; // Status是函数的类型,其值是函数结果状态代码,如OK等
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
void InitStack(SqStack *s)
{
s->base=(SElemType)*malloc(MAXSIZE*sizeof(SElemType));
if(!s->base)
printf("储存内存失败\n");
s->top=s->base;
s->stacksize=MAXSIZE;
}
void Push(SqStack *s,SElemType e) //入栈
{
if(s->top-s->base==s->stacksize)
printf("无法插入!\n");
*s->top=e;
s->top++;
}
void Pop(SqStack *s,SElemType *e) //出栈
{
if(s->top==s->base)
printf("栈空\n");
s->top--;
e=*(s->top);
}
SElemType GetTop(SqStack *s) //取栈顶元素
{
if(s->top!=s->base)
return *(s->top-1);
}
int StackEmpty(SqStack *s) //判断是否为空栈
{
if(s->top==s->base)
return 0;
}
int main()
{
SqStack *s;
InitStack(s);
int flag=1;
char a,x;
scanf("%c",&a);
while(a!='#'&&flag)
{
switch(a)
{
case'(':Push(s,a);break;
case')':if(!StackEmpty(s)&&GetTop(s)=='(')
Pop(s,x);
else
flag=0;
break;
}
scanf("%c",&a);
}
if(StackEmpty(s)&&flag)
printf("匹配成功!\n");
else
printf("匹配失败!\n");
}