通过链表实现Stack

Ras*_*yak 1 c

我收到以下错误消息.无法解决它.谷歌搜索了很多.最后想到把它放在这里.

在此输入图像描述

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int stop;
struct stack
{
  int data;
  struct stack *next;
};
typedef struct stack *node, *top;
//typedef struct stack *top;
void push()
{
    int i;
    struct stack *x;
    x = malloc(sizeof(struct stack));
    printf("\n Enter the element your want to insert");
    scanf("%d", &i);
    x->data = i;
    x->next = top;
    top = x;
}
void pop()
{
    int i;
    if(top == NULL)
    {
        printf("\nStack is empty\n");
    }
    else{
    i = top->data;
    free(top);
    top = top->next;

    }
}
void display()
{
    if(node != NULL)
    {
        printf("%d ", node->data);
        node = node->next;
    }

}
int main()
{
    int ch;
    while(1)
    {
        printf("\nEnter your option \n1. Insert(Push) \n2. Delete(Pop) \n3. Display  : \n");
        scanf("%d", &ch);
        switch(ch)
        {
            case 1:
                    push();
                    break;
            case 2:
                    pop();
                    break;
            case 3:
                    display();
                    break;
            default:
                    printf("Invalid Entery, Try Again");
        }
    }
return 0;
}
Run Code Online (Sandbox Code Playgroud)

gio*_*shc 5

删除typedef,一切都会好的.