如下代码所示,关于malloc与realloc出现5处错误:
#include <stdio.h>
#include <stdlib.h>
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
typedef struct{
int *base;
int *top;
int stacksize;
}SqStack;
void InitStack(SqStack S){
S.base=(int *)malloc(STACK_INIT_SIZE*sizeof(int));
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
}//___________________InitStack_______________________
void Push(SqStack S,int e){
if(S.top==S.base){
S.base=(int *)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(int));
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCREMENT;
}
*S.top=e;
S.top++;
}
void main(){
SqStack S;
InitStack(S);
Push (S,5);
}
SqStack.c
D:\VC6\pvc6\COMMON\MSDEV98\BIN\SqStack.c(13) : error C2143: syntax error : missing ')' before ';'
D:\VC6\pvc6\COMMON\MSDEV98\BIN\SqStack.c(13) : error C2059: syntax error : ')'
D:\VC6\pvc6\COMMON\MSDEV98\BIN\SqStack.c(13) : error C2100: illegal indirection
D:\VC6\pvc6\COMMON\MSDEV98\BIN\SqStack.c(20) : error C2143: syntax error : missing ')' before ';'
D:\VC6\pvc6\COMMON\MSDEV98\BIN\SqStack.c(20) : error C2143: syntax error : missing ';' before ')'
Error executing cl.exe.
SqStack.obj - 5 error(s), 0 warning(s)
求大佬解答~~