#include #include typedef struct{ int x; int y; }Item; typedef struct list{ Item item; struct list *next; }List; List *list = NULL; void push(int x,int y){ List *new_node; new_node = (List*)malloc(sizeof(List)); new_node->item.x = x; new_node->item.y = y; new_node->next = list; list = new_node; } Item pop(){ Item item; List *next; if(list==NULL){ printf("error\n"); item.x=-1; return item; } else { item = list->item; next = list->next; free(list); list = next; return item; } } int main(){ Item item; int i; push(1,2); push(6,3); push(12,43); for(i=0;i<4;i++){ item = pop(); if(item.x>0){ printf("%d %d\n",item.x,item.y); } } }