shiv@ubuntu:~/ds/stack$ cat stack.c /* * Copy right by Shiv Yaragatti * you are free to use, modify and redistribute code on own risk * Interactive C Program to implement STACK using Doubly linked list */ #include "header.h" struct stack { int data; struct stack *next; struct stack *prev; }; typedef struct stack *S; /*Push elements in to stack */ void push(S *stack) { int e; S temp; temp=malloc(sizeof(struct stack)); if(!temp){ printf("Can't allocate memory\n"); return; } printf("Enter element to push\n"); scanf("%d", &e); temp->data=e; if(*stack == NULL){ temp->next = temp->prev = NULL; *stack=temp; } else { temp->next = *stack; (*stack)->prev = temp; temp->prev = NULL; *stack=temp; } } /* Display elements in the stack */...
C and Linux with Examples!!!