0

When using srand(time(0)) function in C program with for loop to print random numbers, what will be seed each time loop runs?

1st Mar 2017, 1:14 PM
Shubham Gupta
Shubham Gupta - avatar
2 ответов
+ 9
If I'm not mistaken, the seed will be the current time since 1/1/1970 in seconds.
1st Mar 2017, 1:24 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
time(0) gives the time in seconds since the date Hatsy stated and that is also the reason you should use the srand function once and not in a loop. repeating it means you resetting the seed which in turn, would cause generating the same number with the rand() function IF the srand was used with the same time
1st Mar 2017, 3:56 PM
Burey
Burey - avatar