What exactly works of a srand() ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What exactly works of a srand() ?

We use rand function for random output, but why we use a srand() ? Why we give seed ? And what has done when we add seed by using srand()

16th Jun 2020, 1:49 AM
Abhishek Porwal
1 Answer
0
look in my code there I used the srand () function: https://code.sololearn.com/cI9E2tOyw6JG/?ref=app In this case, I used the ctime library and thanks to it, the numbers became random. And the fact is that thanks to ctime we got time going back in 1970 (since the time of language c)
16th Jun 2020, 6:56 PM
Alexander
Alexander - avatar