+ 1

Is #include <ctime> necessary?

I've done some programs that use rand(), but I've never included ctime library. Do I need to include that? I usually do include iostream and cstdlib and use: rand(time(NULL)) Can anyone explain me that please? Tanks!

16th Feb 2017, 7:30 PM
Eric Avila
Eric Avila - avatar
2 ответов
+ 2
To use time() you need to include the time header.
16th Feb 2017, 7:49 PM
Robobrine
Robobrine - avatar
+ 1
There is a difference between compilers.
16th Feb 2017, 10:57 PM
전현수
전현수 - avatar