0

C++ RANDOM

Hi guys. I didnt understand random function , how does it work , the srand and the time function in rand and also the seed. I tried to understand on other webistes but NOTHING. Can someone explain me how do they work in simple words thanks.

2nd Jan 2021, 10:01 PM
Hammad Yaqub
Hammad Yaqub - avatar
2 Réponses
+ 2
The rand function is the seed or base for random to work. And the rand function has a predetermined number that every time the program is run it starts with the same number, causing the same results every time it is run again. That is why you have to change the value every time you start your application. from here comes the time. The time always changes it is not static and if you can put it as a seed you can make a random function that every time you start your program it can change the seed automatically
2nd Jan 2021, 11:35 PM
Daniel Briceño
Daniel Briceño - avatar
0
thanks
3rd Jan 2021, 9:57 AM
Hammad Yaqub
Hammad Yaqub - avatar