// Online documentation for the library functions in this
// sample can be found here:
// http://pubs.opengroup.org/onlinepubs/009695399/mindex.html
#include <ctime>
#include <iostream>
using namespace std;
// Three components of a date can be aggregated
// together and always be used as one piece of data:
struct Date {
int month;
int day;
int year;
};
int main()
{
time_t now = time( 0 );
tm time_now;
time_now = *localtime( &now );
cout << ctime( &now );
Date today; // using Date structure to instantiate a variable
today.month = time_now.tm_mon + 1; // month is zero based
today.day = time_now.tm_mday;
today.year = time_now.tm_year + 1900; // year is since 1900
Date bday = today; // copying structures is free - compiler handles it
cout << bday.month;
cout << "/";
cout << bday.day;
cout << "/";
cout << bday.year;
cout << "\n";
return 0;
}