diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index deadcdf..e7db0af 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -89,13 +89,15 @@ int playBJ(int bet, int balance){ int winnings = 0; int userCardsTotal = 0, dealerCardsTotal = 0; - int *dealerCardsArray = (int*) malloc(10 * sizeof(int)); + // Array mit max 10 Karten anlegen + int *dealerCardsArray = (int*) malloc(MAX_CARDS * sizeof(int)); if(dealerCardsArray){ dealerCardsArray[0] = getRandCard(0); printf("computer rand card: %d\n", dealerCardsArray[0]); - int *userCardsArray = (int*) malloc(10 * sizeof(int)); + // Array mit max 10 Karten anlegen + int *userCardsArray = (int*) malloc(MAX_CARDS * sizeof(int)); if(userCardsArray){ @@ -111,7 +113,7 @@ int playBJ(int bet, int balance){ - for(int i = 2; i < 10; i++){ + for(int i = 2; i < MAX_CARDS; i++){ userCardsTotal = calculateCardsTotal(userCardsArray, i); @@ -134,7 +136,7 @@ int playBJ(int bet, int balance){ } - for(int i = 1; i < 10; i++){ + for(int i = 1; i < MAX_CARDS; i++){ dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i); diff --git a/src/main/c/Stefan/blackjack.h b/src/main/c/Stefan/blackjack.h index f20062f..c55c744 100644 --- a/src/main/c/Stefan/blackjack.h +++ b/src/main/c/Stefan/blackjack.h @@ -4,6 +4,7 @@ #include #define ANZ_MOEGLICHE_KARTEN 13 +#define MAX_CARDS 10 int blackjack(); void welcomeMessageBJ();