Added pop() and function prototypes.
This commit is contained in:
parent
1c65ae3672
commit
f0aa621e69
12
lib/stack.c
12
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user