John S. Price john at stat.tamu.edu
Mon Apr 9 09:21:24 AEST 1990

In article <21274 at eerie.acsu.Buffalo.EDU> sicolo at acsu.Buffalo.EDU (james sicolo) writes:
>	What function must one use to get different sequences of random
>numbers each time the program is run????
>	By just using random(), I get the same sequence each time.  Is there
>another function to use ??
>							Jim

You need to seed your random number generator.  If you are
using rand(), use srand() to seed the rrandom number generator.
Send srand() some value that you will know change each time
you run the program, like time(NULL).  So, 


x = rand();   


That's how I do it, anyway...

John Price                   |   It infuriates me to be wrong
john at stat.tamu.edu           |   when I know I'm right....

More information about the Comp.lang.c mailing list