#include //C++ example #include #include using namespace std; int main(int argc, char **argv) { const time_t t = time(0); if (t == static_cast(-1)) { cerr << argv[0] << ": time failed\n"; return EXIT_FAILURE; } const tm *const p = localtime(&t); //initialized and *const cout << "day == " << p->tm_mday << "\n" << "month == " << p->tm_mon + 1 << "\n" << "year == " << p->tm_year + 1900 << "\n"; return EXIT_SUCCESS; }