#include #include "stack.h" #include "node.h" Stack* createStack(){ Stack* s = (Stack*) malloc(sizeof(Stack)); s->top = NULL; s->size = 0; return s; } void push(Stack* stack, int item){ Node* node = (Node*) malloc( sizeof(Node) ); node->data = item; node->next = stack->top; stack->top = node; stack->size += 1; } int pop(Stack* stack){ Node* node = stack->top; stack->top = node->next; stack->size -= 1; return node->data; } int peek(Stack* stack){ return stack->top->data; } int size(Stack* stack){ return stack->size; }