[Solved] Random Number In C Independent Of Time


rand() doesn’t depend on time. People typically seed their pseudo-random number generator using the current time (through the srand() function), but they don’t have to. You can just pass whatever number you want to srand().

If your random numbers aren’t of a high enough quality for your purposes (libc’s rand is notorious for its inadequacy), you should look at other sources of randomness. On most operating systems, you can get high-quality random data just by reading from /dev/random (or /dev/urandom), and the Windows API provides CryptGenRandom. There are also a lot of cross-platform libraries that provide high-quality PRNGS; OpenSSL is one of them.

solved Random Number In C Independent Of Time