0
What is the difference bwtween srand() and rand() functions in C++
3 Respuestas
+ 3
rand() generates pseudo-random numbers, that means numbers that look random but are not.
srand() "seeds" this generator, that means if you call srand in two different programs with the same number as a seed, rand() will then spit out the same numbers over and over again.
That's why you commonly see "srand(time(NULL))", so the seed is different every time you run the program and you get different numbers from rand().
As soon as you know your way around C++, you should stop using rand/srand altogether, and use <random> instead. http://www.cplusplus.com/reference/random/
0
Thank you for your answer. It was really helpful.