+ 1
Please explain this!!!
i don't understand that what is the use of srand() function coz rand() doing the same thing so why we use this function please explain this?
2 ответов
+ 1
srand() is used to seed the random. rand() is not truly random, but just runs a algorithmic pattern of possibilities and will eventually become predictable. Common practice is to seed rand() with the current time in milliseconds each time it is used to make the generator behave more like a true random function.
srand (time(NULL));
printf ("Random number: %d\n", rand()%100);
0
i cant understand how it works.