| 44 | } |
| 45 | |
| 46 | void push(struct nod **top_ref, int n_d) |
| 47 | { |
| 48 | struct nod *new_node = (struct nod *)malloc(sizeof(struct nod)); |
| 49 | |
| 50 | if (new_node == NULL) |
| 51 | { |
| 52 | cout << "Stack underflow \n"; |
| 53 | exit(0); |
| 54 | } |
| 55 | //put items on stack |
| 56 | new_node->d = n_d; |
| 57 | new_node->n = (*top_ref); |
| 58 | (*top_ref) = new_node; |
| 59 | } |
| 60 | |
| 61 | int pop(struct nod **top_ref) |
| 62 | { |