Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. /*struct tm
  9. {
  10.     int tm_sec;
  11.     int tm_min;
  12.     int tm_hour;
  13.     int tm_mday;
  14.     int tm_mon;
  15.     int tm_year;
  16.     int tm_wday;
  17.     int tm_yday;
  18.     int tm_isdst;
  19. };*/
  20.  
  21.  
  22. class Data
  23. {
  24.     public:
  25.     int rok;
  26.     int miesiac;
  27.     int dzien;
  28.  
  29.     void wyswietl()
  30.     {
  31.         cout << "Dzisiejsza data (YYYY-MM-DD) to: " << rok << "-" << miesiac << "-" << dzien << endl;
  32.     }
  33. };
  34.  
  35. int main()
  36. {
  37.     struct tm *czas;
  38.     time_t tim;
  39.     time(&tim);
  40.     czas = localtime(&tim);
  41.     int rok = czas->tm_year + 1900;
  42.     int miesiac = czas->tm_mon + 1;
  43.     int dzien = czas->tm_mday;
  44.    
  45.     Data data;
  46.     data.rok = rok;
  47.     data.miesiac = miesiac;
  48.     data.dzien = dzien;
  49.    
  50.     data.wyswietl();
  51.  
  52.     cout << endl;
  53.    
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement