Is it possible to assign the elements of a 2D array to a 1D array? I'm making a card game where I HAVE TO use a 2D array to create the deck and while dealing the cards, the player has his cards stored in a 1D array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
string player[25] = {};
int x = 0;
int i = 0;
int j = 0;
while (x < 25)
{
player[x] = DeckOfCards[i][j];
++x;
j = j+2;
if (j >= 13)
j == 0;
if (j == 12)
++i;
cout << player[x] << endl; //used this to check if the cards had been dealt properly.
}
This is the part of the code which deals the cards (and they have to be dealt alternately). The program crashes when I run the code (presumably because I'm exceeding dimensions?) DeckOfCards is a [4][13] array.