这个代码那个地方出问题了?
#include<stdio.h>#include<malloc.h>
#define MAXLEN 50 //设定最大长度
#define SIZE 100
typedef struct
{
char name[10];
int age;
}DATA;
typedef struct stack
{
DATA data[SIZE+1]; //数据元素
int top; //栈顶
}StackType;
StackType *STInit()
{
StackType *p;
if(p=(StackType *)malloc(sizeof(StackType))) //申请内存
{
p->top=0; //设置栈顶为0
return p; //返回指向栈的指针
}
return NULL;
}
int STIsEmpty(StackType *s) //判断栈是否为空
{
int t;
t=(s->top==0);
return t;
}
int STIsFull(StackType *s) //判断栈是否已满
{
int t;
t=(s->top==MAXLEN);
return t;
}
void STClear(StackType *s) //清空栈
{
s->top=0;
}
void STFree(StackType *s) //释放栈所占空间
{
if(s)
{
free(s);
}
}
int PushST(StackType *s,DATA data) //入栈
{
if((s->top+1)>MAXLEN)
{
printf("栈溢出!\n");
return 0;
}
s->data
[++s->top]=data; //将元素入栈
return 1;
}
DATA PopST(StackType *s) //出栈
{
if(s->top==0)
{
printf("栈为空!\n");
exit(1);
}
return(s->data[s->top--]);
}
DATA PeekST(StackType *s) //读栈顶数据
{
if(s->top==0)
{
printf("栈为空!\n");
exit(1);
}
return (s->data[s->top]);
}
void conversion(int a,int b)
{
int i;
StackType s;
init(&s);
while(a);
{
Push(&s,a%b);
a=a/b;
}
while(!IsEmpty(&s))
{
i=Pop(&s);
printf("%d",i);
}
}
int main(int argc,char *argv[])
{
int a,b;
printf("please input the data you want to conversion\n");
scanf("%d",&a);
printf("please input the scale you want to convert to\n");
scanf("%d",&b);
conversion(a,b);
return 0;
}