-
Random numbers in C++
I noticed that in BASIC, if you used the RND function get an array of say, 10 characters, it would randomly fill an array with numbers. However, if you ran the program again, those same numbers would always show up. Does this happen in C++. I don't know what the function is, but I can find that pretty easily, so don't worry about that. Thanks if you can help.
-
The random number depends on which seed the random generator gets. Using time(NULL) which returns the number of seconds since a certain date, you always get a unique number.
You set it up with srand(time(NULL)), and then get a random number using rand() % n (a number in the interval 0 to (n-1))
-
680+ posts and you haven't read the FAQ?
-
Alrighty - thanks alot. Hammer - yeah I know - it's a habit I should lose - I'm still used to the old boards - when they only had like 5 or 6 forums.