Niloy007

Piash Vaiya's Problem on Time

Apr 29th, 2021
604
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data