Why ctime() string returned by ctime() have the string ending ( 0x0A ) as its final character? For example, this code:
#include <iostream> #include <cstdlib> int main(int argc, char* argv[]) { time_t now; time(&now); char* time_str = ctime(&now); std::cout << time_str << "why is this on a new line?" << std::endl; return 0; }
... produces the following output:
$ ./time.exe Wed Oct 23 14:52:29 2013 why is this on a new line? $
It does not matter; I can remove the final byte from the string, but why ctime() put it there first?
c ++ c string time std
bythescruff Oct 23 '13 at 14:06 on 2013-10-23 14:06
source share