Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct card_s {
- char suit[20];
- int face;
- struct card_s *next, *previous;
- } card;
- card* createHands(card* head, card *cards) {
- card *tail = NULL, *temp = NULL, *temp1;
- // Go to end of deck
- while (cards->next != NULL) {
- cards = cards->next;
- }
- temp = (card *)malloc(sizeof(card));
- strcpy(temp->suit, cards->suit);
- temp->face = cards->face;
- if (head == NULL) { // If the list for the hand doesn't exist, create head
- head = temp;
- }
- else {
- tail->next = temp;
- }
- tail = temp;
- tail->next = NULL;
- temp1 = cards->previous;
- free(cards); // to delete the node added from the deck
- cards = temp1;
- cards->next = NULL;
- while (cards->previous != NULL) {
- cards = cards->previous;
- }
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement