求助,快快快
#include "stdafx.h"#include<stdio.h>
#include<malloc.h>
#define N 20000
typedef struct astack *stack;
typedef struct astack
{
int top,maxtop;
int*data;
}astack;
stack stacklnit (int size)
{
stack s=(stack)malloc(sizeof*s);
s->data=malloc(size*sizeof(int));
s->maxtop=size-1;
s->top=-1;
return s;
}
void push(int x,stack s)
{
if(s->top>=s->maxtop)printf("stack is full");
else s->data[++s->top]=x;
}
int pop(stack s)
{
if(s->top<0)printf("stack is empty");
else return s->data[s->top--];
}
int main(int argc, char* argv[])
{
int data[N],a;
stack s=stacklnit(N);
s->top=data[0];
push(100, s);
push(200, s);
push(300, s);
a=pop( s);
printf("%d\n",a);
return 0;
}
高手们,我这那出错了,能告诉我吗。