bose@milton.u.washington.edu (Rob Olsen) (02/19/91)
I'm writing a simple poker game to practice using C. At first I used rand() and srand(clock()) for random numbers and it worked ok. Now I want to use GetDateTime(&randSeed) and Random() with printf(), but for some reason I get the same set of random numbers everytime. Is there a way to use Random() and ANSI stdio at the same time? Or should I just forget about Random() and just stick with rand()?
hawley@adobe.COM (Steve Hawley) (02/20/91)
In article <16681@milton.u.washington.edu> bose@milton.u.washington.edu (Rob Olsen) writes: >I'm writing a simple poker game to practice using C. At first I used rand() >and srand(clock()) for random numbers and it worked ok. Now I want to >use GetDateTime(&randSeed) and Random() with printf(), but for some reason >I get the same set of random numbers everytime. Is there a way to use >Random() and ANSI stdio at the same time? Or should I just forget about >Random() and just stick with rand()? I can't tell you why you're getting the same random numbers all the time, but you might want to try this instead: randSeed = TickCount(); /* seed the random number generator */ If you wish to retain the rand() srand() pair to keep compatability, just do what you were already doing. No harm. Steve Hawley hawley@adobe.com -- "Did you know that a cow was *MURDERED* to make that jacket?" "Yes. I didn't think there were any witnesses, so I guess I'll have to kill you too." -Jake Johansen