求高手解决这个问题啊 关于C的
晓飞趋势 2011-06-12 11:55:50 下面是我用C语言编写的程序 (这个程序主要是为了实现十进制转换成16进制)
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct
{
int *base;
int *top;
int stacksize;
}SqStack;
SqStack InitStack(SqStack S)
{
S.top=(int *)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(int));
S.base=(int *)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(int));
if(!S.base)
exit(-1);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
return S;
}
void Push(SqStack S,int e)
{
if(S.top-S.base>=S.stacksize)
{
S.base=(int *)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(int));
if(!S.base)
exit(-1);
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCREMENT;
}
else
*(S.top)++=e;
}
int StackEmpty(SqStack S)
{
if(S.top==S.base)
return 0;
else
return 1;
}
int Pop(SqStack S,int e)
{
if(S.top==S.base)
{
printf("error!\n");
}
else
{
e=*--S.top;
}
return e;
}
void Conversion(SqStack S,int N,int e)
{
while(N){
Push(S,N%16);
N=N/16;
}
}
void print(SqStack S)
{
int e;
printf("转换后:\n");
while(!StackEmpty(S))
{
printf("%d",Pop(S,e));
}
}
int main()
{
int N;
int e;
SqStack S;
printf("请输入十进制数:");
scanf("%d",&N);
S=InitStack(S);
Conversion( S, N, e);
print(S);
}
可是老是出现这个错误
H:\数据结构作业\栈与对列\shuzhi.c(74) : warning C4700: local variable 'e' used without having been initialized
H:\数据结构作业\栈与对列\shuzhi.c(86) : warning C4700: local variable 'S' used without having been initialized
H:\数据结构作业\栈与对列\shuzhi.c(87) : warning C4700: local variable 'e' used without having been initialized
实在是不知道怎么修改了 希望高手帮个忙