diff --git a/lib/stack.c b/lib/stack.c index d57fd96..53a9aaa 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -43,3 +43,15 @@ void push(struct stack *stack, struct card *card) { stack = new_stack; } } + +struct stack *pop(struct stack *stack) { + struct stack *popped_entry = NULL; + + if(!empty(stack)) { + popped_entry = stack; + popped_entry = NULL; + stack = stack->next; + } + + return(popped_entry); +} diff --git a/lib/stack.h b/lib/stack.h index 72daa6f..abb35b4 100644 --- a/lib/stack.h +++ b/lib/stack.h @@ -6,4 +6,10 @@ struct stack { struct stack *next; }; +struct stack *initialize_stack(); +bool empty(struct stack *); +int length(struct stack *); +void push(struct stack *, struct card *); +struct stack *pop(struct stack *); + #endif