各位大哥,帮我看看我的数据结构错在哪里!!!谢谢了
#include<stdio.h>#include<malloc.h>
#define LEN sizeof(struct zhai)
struct zhai
{int data;
struct zhai *next;
};
struct zhai *create(void)
{struct zhai *top;
top=NULL;
return(top);
}
;
int pushzhai(struct zhai *top,int x)
{struct zhai *p;
p=(struct zhai *)malloc(LEN);
if(!p)
{printf("error\n");
return(0);
}
p->data=x;
p->next=top-next;
top->next=p;
return(1);
};
int getzhai(struct zhai *top)
{return(top->data);
};
void main()
{
struct zhai *top;
top=create();
pushzhai(top,1);
pushzhai(top,2);
int i;
i=getzhai(top);
printf("%d",i);
}
为何并不输出2,而输出0并提示错误!!望大侠们指教