srand ( time(NULL) );
j = rand() % 10 + 1;
while (num<=j)
{
srand ( time(NULL) );
r = rand() % 3 + 1;
switch (r)
{case 0:{c = 'a';}break;
case 1:{c = 'b';}break;
case 2:{c = 'c';}break;
default: {cout << "error!!!!";}break;
}
Why would the random int set to r be the same for every instand of the while loop?
meaning every time i run it regardless how many times it runs through the loop every char c is the same for all.

New Topic/Question
Reply



MultiQuote




|