[cs23021-2] srand again

Mikhail Nesterenko mikhail at cs.kent.edu
Sat Oct 31 23:00:33 EDT 2009


CS1 students,

make sure that srand(time()) is called only once in your program.

Remember that time() returns time in seconds. Thus, if time() is
called several times quickly (within a second), it will return the same
value. Which means that srand() will be initialized with the same
seed. Which means that subsequent calls to rand() will return the same
sequence of values.

Thanks,
-- 
Mikhail


More information about the cs23021-2 mailing list