I'm trying to create 2 random numbers. Both numbers must be between 0 and 2 but they cannot be equal to each other. If the first random number is 1, then the second random number must be either 0 or 2 or the program will not exit the loop. For some reason however, I'm ending up with the same number both times thus keeping me in an infinate loop. Here's my code:
do
{ srand((unsigned)time(NULL)); //1st pick
pick1 = rand() % 3;
srand((unsigned)time(NULL)); //second pick
pick2 = rand() % 3;
}while (pick1 == pick2);
How can I fix this? Thanks in advance.
-Goalie35