Need help assigning random numbers to characters
I need help assigning numbers generated to characters. This code should produce a 0 or 1 and I want 0 to equal A and 1 to equal B.
1 2
|
srand(static_cast<unsigned int>(time(0)));
coin_flip = rand() % 2;
|
Don't know if I got the question right, but why don't you simply declare a char variable and use an if? Something like
1 2 3 4 5
|
char c;
if(coin_flip == 0)
c = 'A';
else
c = 'B';
|
Last edited on
Topic archived. No new replies allowed.