为什么这代码没错误,但运行没结果
#include<stdio.h>
#define stacksize 100
struct seqstack{
char data[stacksize];
int top;};
void chushihua(struct seqstack *s)
{
s->top=-1;
}
int panduan(struct seqstack *s)
{
return s->top==-1;
}
void jin(struct seqstack *s,char m)
{
s->data[++s->top]=m;
}
void shuchu(struct seqstack *s)
{
printf("栈的长度为:%d\n",s->top+1);
for(int i=0;i<=s->top;i++)
printf("第%d个元素为:%c\n",i+1,s->data[i]);
}
void main()
{
struct seqstack *s;
chushihua(s);
if(panduan(s))
printf("空栈!!!");
elseprintf("非空栈!!!");
jin(s,97);
jin(s,98);
jin(s,99);
jin(s,100);
shuchu(s);
}
#include<stdio.h>
#define stacksize 100
struct seqstack{
char data[stacksize];
int top;};
void chushihua(struct seqstack *s)
{
s->top=-1;
}
int panduan(struct seqstack *s)
{
return s->top==-1;
}
void jin(struct seqstack *s,char m)
{
s->data[++s->top]=m;
}
void shuchu(struct seqstack *s)
{
printf("栈的长度为:%d\n",s->top+1);
for(int i=0;i<=s->top;i++)
printf("第%d个元素为:%c\n",i+1,s->data[i]);
}
void main()
{
struct seqstack *s;
chushihua(s);
if(panduan(s))
printf("空栈!!!");
elseprintf("非空栈!!!");
jin(s,97);
jin(s,98);
jin(s,99);
jin(s,100);
shuchu(s);
}