0
Help fixing error
Something to do with generating random numbers https://code.sololearn.com/c6tP8mUtjoKH/?ref=app
3 Answers
+ 4
The error is due to the type mismatch of long and time_t (alias of long long). So, declare sec as a variable of type time_t:
time_t sec; time(&sec); ...
It is also possible to directly call time inside srand with a null pointer as time's argument, like this:
srand(time(nullptr));
+ 3
Thank you so much. I have rectified the error. Your answers were helpful, Kinshuk and Julien