我收到以下错误消息。无法解决它。谷歌了很多。终于想到放在这里了。
#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;
}