random number

Alright so i get the whole "rand() % 100 + 1;" deal but i have a slight issue with it. every time the program will return the same numbers in the same order. what's with that.
so my question is, does anyone have any clue as to how to get better random numbers.

(please don't refer me to another site, just answer on the forum as best you can)
every time the program will return the same numbers in the same order.

Seed the random number generator.

(please don't refer me to another site, just answer on the forum as best you can)

Better. Why don't you search this forum as best you can? There must be hundreds of threads covering the topic.
I'll look, Thanks, let you know if i find anything
Okay, thanks i found it.
I had stumbled across it earlier but i didn't know what i was looking at.
thanks for the suggestion.
I think you are seeding the generator at the same time like this:

1
2
3
4
5
srand((unsigned)time(0));
rand % 100 + 1;
srand((unsigned)time(0));
rand % 100 + 1;
etc.


only seed it once at the beginning, since a computer is very fast and the seed takes its seed from the time, it'll seed the generator at pretty much at a nanosecond apart so you'll just get the same answer every time
Topic archived. No new replies allowed.