+ 5
srand and rand
I know that srand generates truly random numbers and rand doesnât, so why does rand even exist? Does it run faster than srand?
1 Answer
+ 10
You're not entirely correct there. srand sets the seed . random numbers are not truly random they are based off of a seed number. if you place the same value in srand each time you will continually pull numbers from the same set. Which is why we use srand usually with the OS time to get a unique number for our seed. Random is the function that actually generates the numbers based off of that seed.