// 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;
// The following is a structure with behavior:
// There is a member function to set the
// current date.
struct Date {
// data fields:
int month;
int day;
int year;
// member functions:
void set_current()
{
time_t now = time( 0 );
struct tm time_now;
time_now = *localtime( &now );
month = time_now.tm_mon + 1;
day = time_now.tm_mday;
year = time_now.tm_year + 1900;
}
};
int main()
{
struct Date today;
today.set_current();
cout << today.month;
cout << "/";
cout << today.day;
cout << "/";
cout << today.year;
cout << "\n";
return 0;
}