编辑代码

#include <stdio.h>
struct stack{
    int top;
    int data[20];
};
void init_stack(struct stack *a){
    a->top=-1;
    printf("初始化成功\n");
}
void stack_push(struct stack *a,int b){
    if(a->top==19){
        printf("栈已满!\n");
        return;
    }
    a->top=a->top+1;
    a->data[a->top]=b;
    printf("成功输入:%d\n",b);
}
int stack_pop(struct stack *a){
    if(a->top==-1){
        printf("栈空!\n");
        return;
    }
    printf("成功弹出:%d",a->data[a->top]);
    return(a->data[a->top--]);
}




int main (void) {
    struct stack a;
    init_stack(&a);  
    stack_push(&a,1);
    stack_pop(&a);

	return 0;
}