// // Filename: pgm3_3a.cpp // // Description: Demonstration of the 'time()' function call. // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 03/02/98 // Last Modified: 03/02/98 // // Name: N/A // #include #include #include #include #include int main( int argc, char *argv[] ) { // // 'time_t' is a new data type used to represent time in seconds. // time_t temp; // // 'unsigned long' is a BIG nonnegative integer! // unsigned long seconds; unsigned long minutes; unsigned long hours; unsigned long days; unsigned long years; // // Get the number of seconds since Jan 1, 1970! // temp = time( NULL ); cout << "Number seconds since 1970: " << temp << endl; seconds = temp % 60; temp = temp / 60; minutes = temp % 60; temp = temp / 60; hours = temp % 24; temp = temp / 24; days = temp % 365; temp = temp / 365; years = temp % 365; cout << "\nThat is:" << endl; cout << "\t" << years << " years," << endl; cout << "\t" << days << " days," << endl; cout << "\t" << hours << " hours," << endl; cout << "\t" << minutes << " minutes," << endl; cout << "\tand\n"; cout << "\t" << seconds << " seconds \n" << endl; cout << "The date the file was compiled was: " << __DATE__ << endl; cout << "The time the file was compiled was: " << __TIME__ << endl; return 0; }