Mail Archives: djgpp/1998/02/04/17:47:54
Jason wrote:
<< Basically, I'd like a program to (automatically) seed srand() with a
different value each time the program is run. (Currently I require the
user to type in a seed, which is a nuisance.) Initially, I thought
something as simple as srand(clock()) would work, but then I found out
that clock() only returns the number of clock ticks since the *last*
call of clock(), so clock() always returns the value 0 when called for
the first time.>>
I think srand(time(NULL)); might be what your looking for.
- Raw text -