I read the explenations but I couldn't figure out the purpose of srand(), can somebody explain how it works? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I read the explenations but I couldn't figure out the purpose of srand(), can somebody explain how it works?

7th Jul 2016, 3:08 PM
Stev
2 Answers
+ 4
So you get how rand() works, right? It has its own list of "random" numbers that it uses every time. But, with srand(), you can choose a new list of "random" numbers. Each different number you use in srand() will provide it's own list of "random" numbers for rand() to use.
8th Jul 2016, 6:26 AM
Purple Viking
Purple Viking - avatar
+ 1
@Purple Viking Ty , I understand now.
9th Jul 2016, 12:36 AM
Stev