int main(void) { int method, val; Node *head; head=NULL; puts("Input a method(1 and a value to push, 0 to pop, 2 to show the top) or -1 to quit:"); while(scanf("%d", &method)) { switch(method) { case -1: while(head!=NULL){ stack_pop(&head); } return 0; case 0: stack_pop(&head); break; case 1: scanf("%d", &val); stack_push(&head, val); break; case 2: stack_top(head); break; default: puts("Error Method!!"); break; } stack_display(head); } }
int main() { struct node *top; int item; top=NULL; push(&top,11); push(&top,12); push(&top,13); push(&top,14); push(&top,15); push(&top,16); stack_display(top); printf("\n"); printf("No. of items in the stack %d",count(top)); printf("\n Items extreacted from stack=%d",pop(&top)); printf("\n Items extreacted from stack=%d",pop(&top)); printf("\n Items extreacted from stack=%d",pop(&top)); printf("\n No. of items in the stack %d",count(top)); stack_display(top); }