Question: How to shuffle/randomize a linked list in C? I am currently creating an UNO game in C. I have to use a linked list to

How to shuffle/randomize a linked list in C?

I am currently creating an UNO game in C. I have to use a linked list to create the deck (consisting of 108 cards). I need to implement a shuffle function to randomly shuffle the deck, but i am pretty lost on where to start.

Here is a picture of the code I have so far.

How to shuffle/randomize a linked list in C? I am currently creating

#include 10 #include 12 typedef struct card s f 13 14 15 16 17card; 18 19 void print_list(card headp) char suit [71; int value; char action[15]; struct card s *pt (headp printf("%s %d headp while NULL){ %s != ", headp->suit, headp->value, headp->action); headp->pt; = printf("n" 25 28 29 int main(void) 30 int choice; card?eadp=NULL, FILE *fp 32 *temp , *tail=NULL; 35 fpfopen("Uno_Deck.txt", "r"); (card)); *)malloc(sizeof "%s NULL){ temp (card = while %d temp->suit, &temp->value, temp->action) EOF){ (fscanf(fp, if 38 %s", != (head p = 40 headp temp ; else tail = temp ; tail->pt = NULL; temp(card *) malloc(sizeof (card)); 45 fclose(fp); printf("Let's Play a Game of UNO "); printf("Press 1 to shuffle the UNO deck or 2 to load a deck from a file: "); scanf ( "%d", &choice); if (choice 1)( 52 if (choice2) printf("The deck has been loaded in. "; print list (headp); return 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!