From 18cf7959144f059d9a03d7758c45a7f0a3ec2a0c Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Fri, 9 Apr 2010 00:49:17 -0300 Subject: [PATCH] Added function to move cards between stacks. --- lib/stack.c | 9 +++++++++ lib/stack.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/stack.c b/lib/stack.c index 21fa5d8..e712ac9 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -73,3 +73,12 @@ struct stack *pop(struct stack **stack) { return(popped_entry); } + +void move_card(struct stack **origin, struct stack **destination) { + struct stack *stack = NULL; + + stack = pop(origin); + push(destination, stack->card); + + return; +} diff --git a/lib/stack.h b/lib/stack.h index 2f3a79b..7c6e212 100644 --- a/lib/stack.h +++ b/lib/stack.h @@ -15,5 +15,6 @@ bool empty(struct stack *); int length(struct stack *); void push(struct stack **, struct card *); struct stack *pop(struct stack **); +void move_card(struct stack **, struct stack **); #endif