rahzab @ 2008-07-26, 1:53 pm wrote:
Another question;
I understand that srand(time)0)) generates a number that is based on the current system time, however, what were to happen if i change the (time(0)) in the argument?
I appreciate the help.
MOD EDIT:Remember the syntax tags!
srand() sets the random number generator seed, it does not return a random number. When you set the random number seed ot time you are setting it to something that you can be fairly certain is different every time you run your program, so the seed is always different. If you call srand(0) at the start of your program you will always get the same pattern of random numbers.
Ideally you only call srand() once and then call rand() whenever you need a random number. It's quite possible for your program to run so fast that time(0) (which returns the current number of seconds since the epoch) will remain the same, which means that everytime you call srand() your resetting hte seed to the same number.