Question
Hi, I need help with fixing these two functions. This program is for a UNO card game. The function is the discard pile. I'm not
Hi, I need help with fixing these two functions. This program is for a UNO card game. The function is the discard pile. I'm not sure how to add the card to the discard list and change the head of the discard to the new card from the player's hand.(which is a list as well). Right now its not changing the head of the discard list.
Any changes or advice would be appreciated.
void discard_fun(card *handp, card **discardHead, card **discardTail, int input) {
card *target = handp;
card *previous = NULL;
int i;
for (i = 0; i < input; i++) {
previous = target;
target = target->next;
}
previous->next = target->next;
target->next = handp;
handp = target;
previous->value = (target)->value;
strcpy(previous->suit, (target)->suit);
strcpy(previous->action, (target)->action);
(*discardTail)->next = previous;
*discardTail = previous;
(*discardTail)->next = NULL;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started