第一次发帖,多多捧场,问题有点急
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define STACK_INIT_SIZE 20
#define INCERTMENT 10
typedef char elemtype;
typedef struct{
    elemtype *top;
    elemtype * base;
    int stacksize;
    
} stack;
void initstack(stack *s)
{
    s=(stack *)malloc(STACK_INIT_SIZE*sizeof(elemtype));
    if(!s) exit(0);
    s->top=s->base;
    s->stacksize=STACK_INIT_SIZE;
}
void push(stack *s,elemtype e)
{
    if(s->top-s->base>=s->stacksize)
        s->base=(elemtype *)realloc(s->base,(STACK_INIT_SIZE+INCERTMENT)*sizeof(elemtype));
        s->top=s->base+s->stacksize;
        *(s->top)=e;
        s->top++;

}
void pop(stack *s,elemtype e)
{if(s->base==s->top)
 printf("栈为空");
 e=*--(s->top);
}
int match(char e,char c)
{
if(e=='('&&c==')')
  return 1; 
if(e=='['&&c==']')
  return 1;
}
int stacklen(stack *s,int l)
{
    l=s->top-s->base;
    return l;

}

void main(stack *s,elemtype e)
{
 char c[100];
 int i,ch;
 for(i=0;ch=getchar()!='\n';i++)
 {    c[i]=ch;
 if(c[i]=='('||c[i]=='[')
     push(s,e);
 if(c[i]==')'||c[i]==']')
     pop(s,e);
    if(!match(e,c[i]))
    printf("不匹配");
 
    }
    printf("括号匹配");
    free(s);
}