Array is not reading out anything after rand()

I'm trying to understand why I cannot read out and see what the random function filled my array up with.

I initialized my array to spaces. Then I thought I filled up my array with the random function. I then used a for loop to read out the data in my array.

I'm guessing there is something I'm not understanding about the random function. Here is my code attached below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int suit, face;
    char CardDeck[4][13];
    int r = 0;
    int c = 0;
    srand((unsigned int)time(0));
    
    
    for (r = 0; r < 4; r++)
    {
        for (c = 0; c < 13; c++)
        {
            CardDeck[r][c] = ' ';
            cout << setw(3) << CardDeck[r][c];
        }
        cout << endl;
    }
    do {
        suit = rand() % 4;
        face = rand() % 13;
    } while (CardDeck[r][c] != ' ');
    
    for (r = 0; r < 4; r++)
    {
        for (c = 0; c < 13; c++)
        {
            cout << setw(3) << CardDeck[r][c];
        }
        cout << endl;
    }

    
    

    return 0;
}

1
2
3
4
 do {
        suit = rand() % 4;
        face = rand() % 13;
    } while (CardDeck[r][c] != ' ');


This doesn't do anything useful. What are you trying to do here?
Topic archived. No new replies allowed.