Iam doing this:
auto clockNow = std::chrono::system_clock::now();
auto clockDateNow = std::chrono::system_clock::to_time_t(clockNow);
std::cout << "finished computation at " << std::ctime(&clockDateNow);
And i get this compiler error: " ‘ctime’: This function or variable may be unsafe. Considering using ctime_S instead. To disable depcrecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. "
PS First timer, using ctime and kinda chronos too…
Let met guess, are you using Visual Studio?
*_s variants are Microsoft specific and will not be able to be cross compiled for other systems. I suggest you just ignore these errors, or use a different function.
Yes youre right sir! vs 2017… thanks!
PS hi again, so how exactly do i do that lol
Basically, just stick with chrono and ditch ctime. In the link theres a way to get time from chrono.
ctime_s is part of C11, which means to use it in gcc you will need to just specify
_s stands for safe, as you provide a buffer to return the value into rather then using a shared buffer that could get updated when writing multi threaded applications.