数值转换器不知道出了什么问题,高手来看看
#include<iostream.h>#include<malloc.h>
#include<stdio.h>
#include<process.h>
#define TURE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define STACK_INIT_SIZE 100;
#define STACKINCREMENT 10;
typedef int Status;
typedef int SElemType;
typedef int Boolean;
typedef struct{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
Status InitStack(SqStack &S)
{
S.base = (SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));
if(!S.base) exit(OVERFLOW);
S.top = S.base;
S.stacksize = STACK_INIT_SIZE;
return OK;
}
Status PushStack(SqStack &S, SElemType e)
{
if(S.top - S.base >= S.stacksize)
{
S.base = (SElemType *)realloc(S.base,(S.stacksize+STACKINCREMENT) * sizeof(SElemType));
if(!S.base) exit(OVERFLOW);
S.top = S.base + S.stacksize;
S.stacksize += STACKINCREMENT;
}
*S.top++ = e;
return OK;
}
Status PopStack(SqStack &S, SElemType e)
{
if(S.top == S.base) return ERROR;
e = * --S.top;
return OK;
}
Status StackEmpty(SqStack S)
{
if(S.top == S.base)
return TURE;
else return FALSE;
return OK;
}
void conversion(int N,int r)
{
SqStack S;
SElemType e;
InitStack(S);
if(N<0)
{
cout<<"您输入的数据不在范围之内!";
cout<<endl;
return;
}
if(!N)
PushStack(S,0);
while(N)
{
PushStack(S,N%r);
N = N/r;
}
while(!StackEmpty(S))
{
PopStack(S,e);
cout<<"\t"<<e;
}
}
void main()
{
int N,r;
cout<<"请输入任意一个整数: ";
cin>>N;
cout<<endl;
cout<<"请输入要转换的进制: ";
cin>>r;
cout<<endl;
conversion(N,r);
}
以上是我写的代码,不知道为什么老出现
error C2143: syntax error : missing ')' before ';'和error C2059: syntax error : ')'。
出错的地方是S.base = (SElemType *)realloc(S.base,(S.stacksize+STACKINCREMENT) * sizeof(SElemType));
和S.base = (SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType));
小弟初学望高手指点,在这先谢谢了