Thursday, July 9, 2009

Srand((unsigned)time(NULL)); x[index] = rand()%max; Can anyone explains what this means and do?

It's part of RandomNumberGeneration...C++

Srand((unsigned)time(NULL)); x[index] = rand()%max; Can anyone explains what this means and do?
srand((unsigned)time(NULL));


seeds the random number generator based on the time. what that means is that it tells the random number generator where to start when you call the random number generator.





x[index] = rand()%max;


is filling an array "x" with random numbers


0 comments:

Post a Comment