帮我看下我这个栈有什么问题啊
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#define SIZE 4
#define NUM 4
typedef struct stack{
int date;
struct stack *next;
}S;
int push(S *s, int con)
{
S *p;
p=(S *)malloc(sizeof(S));
if(!p){
return -1;
}
p->date=con;
p->next=s;
s=p;
return 0;
}
int pop(S *s, int *con)
{
S *p;
int cont;
if( s== NULL){
return -1;
}
printf("%d\n",s->date);
p=s;
*con=p->date;
s=p->next;
free(p);
return 0;
}
int main(void)
{
S *s;
char buf[SIZE];
int i=0, dat, cout;
while((i++) < NUM){
fgets(buf, SIZE, stdin);
dat=atoi(buf);
push(s, dat);
}
printf("%d\n",s->date);
while(--i){
if(!pop(s, &cout)){
printf("%d\n",cout);
}
}
return 0;
}