Advertisement
Niloy007

Piash Vaiya's Problem on Time

Apr 29th, 2021
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4.  
  5. int main() {
  6.     time_t rawtime;
  7.     struct tm *timeinfo;
  8.  
  9.     time(&rawtime);
  10.     timeinfo = localtime(&rawtime);
  11.     int controlHour = timeinfo->tm_min;
  12.     controlHour += 4;
  13.     controlHour %= 24;
  14.     while (timeinfo->tm_hour != controlHour) {
  15.         printf("Current local time and date: %s", asctime(timeinfo));
  16.         time(&rawtime);
  17.         timeinfo = localtime(&rawtime);
  18.     }
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement