数据结构C程序栈的问题

目的:将输入的数字转为二进制,接着将转换后的元素入栈。全部入栈完再把元素一个个出栈,出栈的结果即为转换完的结果

我的问题:运行无报错,但输入数字运行没有结果

#include
#include
#include
#include
#include "process.h"
#define SIZE 100// 存储空间初始分配
#define STACKINCREMENT 10// 存储空间分配增量
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
typedef int Status;
typedef int SElemType;
typedef struct
{
    SElemType *base;//栈底
    int *top;//栈顶
    int stacksize;//栈容量
} SqStack;
SqStack *S; //定义全局变量


 //初始化栈
int InitStack(SqStack *S) {
S->base=(SElemType*)malloc(SIZE*sizeof(SElemType));
if(!S->base)exit(OVERFLOW);
S->top=S->base;
S->stacksize=SIZE;
return OK;
}

//入栈操作 
void Push(SqStack *S, int e){

if(S->top-S->base>=S->stacksize){
S->base=(SElemType*)realloc(S->base,(S->stacksize+10)*sizeof(SElemType));
if(!S->base)exit (OVERFLOW);
S->top=S->base+S->stacksize;
S->stacksize+=10;    
}
S->top=&e;
S->top++;
}

//判空操作 
Status Stackempty(SqStack *S){
if(S->top==S->base) return ERROR;
return OK;
}

// 出栈操作
void Pop(SqStack *S){
    SElemType *e;
if(S->top==S->base)  printf("ERROR");
else *e=*--S->top ;
    printf("%d",*e);
}

//数制转换函数 
void conversion(SElemType N, SqStack *S){
InitStack(S);
while(N>=0){
    Push(S,N%2);
    N=N/2;}
while(!Stackempty(S)){

    Pop(S);
}
}

 //主函数 
int main(){
SElemType N; 
printf("输入要转换的数字N\n");
scanf("%d",&N);
printf("转换结果为:");
conversion(N,S);
return 0;
}

修改如下,改动处见注释,供参考:

#include <stdio.h>
#include <stdlib.h>
//#include <>
//#include <>
//#include "process.h"
#define SIZE 100// 存储空间初始分配
#define STACKINCREMENT 10// 存储空间分配增量
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -1
typedef int Status;
typedef int SElemType;
typedef struct
{
    SElemType* base;//栈底
    int* top;//栈顶
    int stacksize;//栈容量
} SqStack;
SqStack* S; //定义全局变量
 //初始化栈
int InitStack(SqStack** S) {  //修改
    (*S) = (SqStack*)malloc(sizeof(SqStack)); //修改
    (*S)->base = (SElemType*)malloc(SIZE * sizeof(SElemType));  //修改
    if (!(*S)->base) exit(OVERFLOW);   //修改
    (*S)->top = (*S)->base;             //修改
    (*S)->stacksize = SIZE;             //修改
    return OK;
}
//入栈操作 
void Push(SqStack* S, int e) {
    if (S->top - S->base >= S->stacksize) {
        S->base = (SElemType*)realloc(S->base, (S->stacksize + 10) * sizeof(SElemType));
        if (!S->base)  exit(OVERFLOW);
        S->top = S->base + S->stacksize;
        S->stacksize += 10;
    }
    *S->top = e; //S->top = &e;  修改
    S->top++;
}
//判空操作 
Status Stackempty(SqStack* S) {
    if (S->top == S->base) 
        return OK;          //修改
    return ERROR;           //修改
}
// 出栈操作
void Pop(SqStack* S) {
    SElemType e;  //SElemType* e; 修改
    if (S->top == S->base) 
        printf("ERROR");
    else {                 //修改
        e = *--S->top;     //修改
        printf("%d", e);  
    }                      //修改
}
//数制转换函数 
void conversion(SElemType N, SqStack* S) {
    //InitStack(S);    //修改
    while (N > 0) {   //while (N >= 0) 修改
        Push(S, N % 2);
        N = N / 2;
    }
    while (!Stackempty(S)) {
        Pop(S);
    }
}
//主函数 
int main() {
    SElemType N;
    InitStack(&S);  //修改
    printf("输入要转换的数字N\n");
    scanf("%d", &N);
    printf("转换结果为:");
    conversion(N, S);
    return 0;
}