It may be that you understand what you mean but expressed it poorly, but your two posts could be considered misleading.

srand() doesn't generate random numbers, it seeds the random number generator. rand() doesn't generate the same number each time it's called, it returns the next number in the sequence. If you don't seed the generator before your first call to rand() it may start the sequence from the same point each time.

What are you using the random values for?

rand() is a very poor random number generator, useless for almost everything except for student exercises. If you are doing simulations (or, heaven forbid, cryptography) you will find that rand() is going to give anomalous results. In addition, it only provides a small set (it only provides numbers between 0 and 32767 and if I recall correctly, providing a different seed to srand() only shifts your starting point in the exact same sequence of random numbers.

Re: What are you using the random values for?

Originally posted by mitakeet rand() is a very poor random number generator, useless for almost everything except for student exercises. If you are doing simulations (or, heaven forbid, cryptography) you will find that rand() is going to give anomalous results. In addition, it only provides a small set (it only provides numbers between 0 and 32767 and if I recall correctly, providing a different seed to srand() only shifts your starting point in the exact same sequence of random numbers.

It provides at least 0 to 32767. Some implementations provide a greater range.

The RAND_MAX macro is set to equal to the maximum range rand() returns. It has been 32,767 on every machine I have tested it on (all Windows OS's). srand() does simply shift the starting point in the sequence, since rand() just returns the next number in the sequence based on the current number, the sequence is always the same.

You could attempt to use the least significant bits of the current time via high resolution timer, if one exists, to help construct a random number. These bits from the current time should be fairly random by themselves.

The random generator isn't for anything too fancy. I just have to write a small program in C that implements MPI on our computer cluster. I was just trying to figure out how to make calls to random processes. Thank you all for your help! I think I am all set now.