Kod :
#include <time.h>
#include <iostream>
#include <windows.h>
using namespace std;
int main ()
{
time_t t = time(0);
struct tm * then = localtime( & t );
cout << (then->tm_year + 1900) << '-'
<< (then->tm_mon + 1) << '-'
<< then->tm_mday << " "
<< then->tm_hour << ":"
<< then->tm_min << ":"
<< then->tm_sec << endl;
Sleep(4000);
time_t t2 = time(0);
struct tm * now = localtime( &t2 );
cout << (now->tm_year + 1900) << '-'
<< (now->tm_mon + 1) << '-'
<< now->tm_mday << " "
<< now->tm_hour << ":"
<< now->tm_min << ":"
<< now->tm_sec << endl;
double gone = difftime(t2,t);
cout << gone << " seconds are gone forever." << endl;
return 0;
}
Zakładki