# Thread: Rand() not bieng very random

1. ## Rand() not bieng very random

Sorry it's me again.

Anyway, the title pretty much explains it all. My program chooses five random numbers ranging from 1-5, (inclusive,) but it always chooses the same numbers in the same order. Is this normal? I ask simply because I wish to know the nature of rand(). I just can't see how any proccess a system performs can be random, as it has pre-set commands to determine these numbers. Can anyone explain the concept of random number generating? If you can please do as I am really lost.

Thanks for any replies.
Necrofear

2. Have you seeded rand() Generate random numbers?

3. No I hadn't. I wasn't sure how to generate a random seed, but I've just read the example you gave me, (Cheers for the link BTW,) and I'm going to try to use time as a seed like they did.

Necrofear

P.S. I like your avatar. House is an amazing show! Thanks again

4. [/offtopic]

Originally Posted by twomers
Have you seeded rand() Generate random numbers?
Fran ? :P

5. You talking about my sig, zacs7? I think it was Bernard, not Fran who said it.

6. Yeah I know , just Fran was in there somewhere , Ep with her shrinking walls methinks.

7. Cheers for the rand() info.
I got the seed changing every execution now.

Thanks for the help!
Necrofear

8. If you want to get different random numbers each time you run your program, you will also need to use the srand() function as well, as this will seed the generator. The srand() function is called only once during a programs execution.
....

9. Originally Posted by zacs7
....
???

If you mean what I think you mean by: ... , then I mean that every time the program is executed, it uses a different seed. Not that it changes seed halfway through. It use to always start at the same place.

If you don't mean what I think you mean however then I'm confused.

10. Bah, sorry I thought you ment every loop execution (iteration)

11. fyi they will only be pseudo random numbers not real randoms