I've created a function that creates a new deck for a Blackjack game I'm making. When I had the algorithm in the main function it worked but when moved to a function problems started to sprout up. It's hard to explain the problem but it's a short code so I'm sure compiling it won't be a problem.
#include <iostream>
void new_deck(unsignedint Cards[52]);
int main()
{
usingnamespace std;
unsignedint Cards[52];
int i;
new_deck(Cards);
for (i = 0; i < 52; i++)
cout << Cards[i];
cout << "\nPress ENTER to exit\n";
cin.get();
cin.get();
return 0;
}
void new_deck(unsignedint cards[52])
{
int i, cardValue = 2;
for (i = 0; i < 52; i++)
{
if (cardValue > 11 && i < 40)
cardValue = 2;
elseif (i == 40)
cardValue = 10;
cards[i] = cardValue;
if (i < 40)
cardValue++;
}
}