Help fixing error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help fixing error

Something to do with generating random numbers https://code.sololearn.com/c6tP8mUtjoKH/?ref=app

27th Feb 2019, 5:54 PM
Agaba Edwin
Agaba Edwin - avatar
2 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));
27th Feb 2019, 6:33 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 3
Thank you so much. I have rectified the error. Your answers were helpful, Kinshuk and Julien
27th Feb 2019, 7:23 PM
Agaba Edwin
Agaba Edwin - avatar