I display the current date/time via
#include <ctime>
time_t sec = time(NULL);
tm* curTime = localtime(&sec);
cout << "Date: " << curTime->tm_mday << "." << curTime->tm_mon << "." << curTime->tm_year+1900 << endl;
cout << "Time: " << curTime->tm_hour << ":" << curTime->tm_min << ":" << curTime->tm_sec << endl;
Actually it displays e.g.
Date: 4.10.2016
Time: 9:54:0
I got 2 problems here:
Thanks for all your help :)
You should use manipulators for printing. in printf("%02d", curTime->tm_hour) in cout, you can use, std::cout << std::setw(2) << std::setfill('0') << curTime->tm_hour.
tm_mon is from 0 to 11. So you should use tm_mon+1 for printing.