布包女:有关堆栈

来源:百度文库 编辑:高考问答 时间:2024/05/05 00:42:30
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include<malloc.h>
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
#define OVERFLOW -1
enum BOOL{OK,ERROR};

typedef struct{//
char *basel;
char *topl;
char *baser;
char *topr;
int stacksize;
}SqStack;
BOOL InitStack(SqStack &);
BOOL GetTop(SqStack,char &);
BOOL Push(SqStack &,char );
BOOL Pop(SqStack &,char);

void main()
{SqStack S;
InitStack(S);
}

BOOL InitStack(SqStack &S)
{
S.basel=(char *)malloc(STACK_INIT_SIZE * sizeof(char));
if(!S.basel) exit(OVERFLOW);
S.stacksize=STACK_INIT_SIZE;
S.topl=S.basel;
S.baser=S.basel+S.stacksize;
S.topr=S.baser;
return OK;
}

出现:\Documents and Settings\Guest\My Documents\lee\ds\实验二\相向栈\相向.CPP(30) : error C2143: syntax error : missing ')' before ';'
C:\Documents and Settings\Guest\My Documents\lee\ds\实验二\相向栈\相向.CPP(30) : error C2059: syntax error : ')'
C:\Documents and Settings\Guest\My Documents\lee\ds\实验二\相向栈\相向.CPP(30) : error C2100: illegal indirection
Error executing cl.exe.

无语了,第一条就让人没脾气,各位能仙人指路吗?
而且还讲位置不对???不清楚了

#define OVERFLOW -1 后面少一个分号。

#define语句一般不加分号吧?