For genarete random number, we use rand().. But theres also a function that is recommanded to use to initialize randon number srand()..
Then what is that srand().. What is the initialization of random number?.. What would happen if I dont use srand()?.. How do everyone set value of it in dffrent cases?..
Plz anyone clear this matter to me.. I'm not understanding anything by the tutorial of this site about srand()
rand() returns a pseudo random number. If you call rand() without seeding the random number generator (RNG), rand() will always return the same sequence of numbers.
srand() allows you to seed the starting point the RNG uses. srand() is usually called with time() as an argument which gives you a relatively random starting point srand() should only ever be called ONCE in your program. If you call it multiple times in the same second, you're going to reset the RNG to exactly the same sequence.