这个程序为什么能跑,但是没有输出
//进制转换
#include<iostream>
using namespace std;
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define MAXSIZE 100
typedef int SElemType;
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack ;
int InitStack(SqStack &S)//构造一个空栈
{
S.base==new SElemType[MAXSIZE];
if(!S.base)
exit(OVERFLOW);
S.top=S.base;
S.stacksize=MAXSIZE;
return OK;
}
int Push(SqStack &S,SElemType e)//入栈
{
if(S.top-S.base==S.stacksize)
return ERROR;
*S.top++=e;
return OK;
}
int StackEmpty(SqStack S)
{ /* 若栈S为空栈,则返回TRUE,否则返回FALSE */
if(S.top==S.base)
return OK;
else
return ERROR;
}
int Pop(SqStack &S,SElemType &e)
{
if(S.top==S.base)
return ERROR;
e=*--S.top;
return OK;
}
int main() {
SqStack S;
int N, e;
InitStack(S);
printf("请输入一个十进制数:");
scanf("%d", &N);
while (N) {
Push(S, N % 8);
N = N / 8;
}
printf("转换为八进制数为:");
while (!StackEmpty(S)) {
Pop(S, e);
printf("%d", e);
}
printf("\n");
return 0;
}