哪位大神帮我看看这里怎么了,有关于栈的操作的,虚心请教,求解释
#include <stdio.h>#define size 50
#include <malloc.h>
#define OVERFLOW -1
#define OK 1
#define ERROR 0
typedef int elemtype;
typedef int status;
typedef struct
{
elemtype base[size];
int top;
}stack;
void initstack(stack *s)
{//初始化空栈
s->top=-1;
}
void push(stack *s,elemtype e)
{//元素进栈
s->top++;
s->base[s->top]=e;
}
void output(stack *s)
{//output all elements in the stack s
int i;
for(i=s->top;i>=0;i--)
{
printf("%-5d",s->base[i]);
}
}
status gettop(stack s,elemtype topelem)
{//get the top element of stack s
topelem=s.base[s.top];
return topelem;
}
void delstack(stack *s)
{//删除栈顶元素
s->base[s->top--]=0;
}
void main()
{
stack *s;
int flag=1,a,temp,i;
initstack(s); warning C4700: local variable 's' used without having been initialized
printf("十进制转八进制\n请输入一个十进制数a=");
scanf("%d",&a);
temp=a;
while(temp!=0)
{
i=temp%8;
push(s,i);
temp=temp/8;
}
printf("%d的八进制代码为",a);
output(s);printf("\n");
}
[ 本帖最后由 暗静暗静呢 于 2015-6-27 13:37 编辑 ]