Here Goes...
I believe I am using the Srand and Rand functions correctly but I am calling them in a loop. I believe the loop is iterating too quickly and the rand() is not changing it's values.
If I do this, all card values are returned as 0. If I do not have the srand the function returns random numbers but they are the same everytime. What can I do to over come this?
Secondly, I know that the number is not changing because I am adding them up in an array, and one specific element will receive the numbers of times the for loop has run. Where the rand() function always returned 3. Any help?
Thanks,
Ron
cout << "If you don't know where you want to go, we'll make sure you get taken";
I believe I am using the Srand and Rand functions correctly but I am calling them in a loop. I believe the loop is iterating too quickly and the rand() is not changing it's values.
Code:
srand( static_cast<unsigned int>(time( NULL )) );
int Card = (1+rand())%13;
If I do this, all card values are returned as 0. If I do not have the srand the function returns random numbers but they are the same everytime. What can I do to over come this?
Secondly, I know that the number is not changing because I am adding them up in an array, and one specific element will receive the numbers of times the for loop has run. Where the rand() function always returned 3. Any help?
Code:
OutPut:
[green]
myFreq[ 0] 0
myFreq[ 1] 0
myFreq[ 2] 0
myFreq[ 3] 1000
myFreq[ 4] 0
myFreq[ 5] 0
myFreq[ 6] 0
myFreq[ 7] 0
myFreq[ 8] 0
myFreq[ 9] 0
myFreq[10] 0
myFreq[11] 0
myFreq[12] 0
myFreq[13] 0
myFreq[14] 0
myFreq[15] 0
myFreq[16] 0
myFreq[17] 0
myFreq[18] 0
myFreq[19] 0
myFreq[20] 0
myFreq[21] 0
myFreq[22] 0
myFreq[23] 0
myFreq[24] 0
[/green]
Thanks,
Ron
cout << "If you don't know where you want to go, we'll make sure you get taken";