I'm building a basic card game, and for that I must create a deck of card (not a regular deck of cards though) and shuffle it. It was working quite well on Visual Studio (Windows 10), but once I switched to Xcode (Mac OS X 10.11.16) I can't seem to get the same results.
Here is my main.c, referencing my .h file:
#include "Card.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
Card* lst = NULL;
if(CRD_createDeck(lst) != CRD_retCondOK)
printf("Something is wrong\n");
CRD_showDeck(b);
if(b == NULL)
printf("Empty\n");
return 0;
}
My Card.h file defines Card* b:
static Card* b;
And my Card.c file:
#include "Card.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
CRD_tpRetCond CRD_createDeck(Card* lst){
int numCards, numSuits, CardEnum = 1;
char vetCardName[10] = {'4', '5', '6', '7', 'Q', 'J', 'K', 'A', '2', '3'};
char vetCardSuit[4][8] = {"Ouros", "Espadas", "Copas", "Paus"};
/*
lst = CRD_createList();
if(lst != NULL)
return CRD_retCondCreateError;*/
CardInfo* generico;
for(numSuits = 4; numSuits >= 1; numSuits--){
for(numCards=10;numCards >= 1; numCards--) {
generico = CRD_createCard(vetCardName[numCards-1],numCards,vetCardSuit[numNaipes-1],numSuits);
lst = CRD_insertCard(lst,generico,CardEnum);
CardEnum++;
}
}
b = lst;
CRD_showDeck(b);
return BAR_CondRetOK;
}
I apologize if there are any inconsistencies with the variable names, I quickly translated from portuguese to English to give you all a better idea. When I call the function CRD_showDeck(b), it correctly shows all of the cards in the deck. However, my main function considers b to be empty. Why is this happening?