Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <time.h>
  4. #include <unistd.h>
  5.  
  6. void clearConsole(const unsigned int clearHeight);
  7.  
  8. int main() {
  9.     bool inProgress = true;
  10.     time_t startTime = time(NULL);
  11.    
  12.     while(inProgress) {
  13.         sleep(1);
  14.        
  15.         if(difftime(time(NULL), startTime) == (24 * 60)) {
  16.             clearConsole(50);
  17.            
  18.             printf("Go check the oven, bud.\n");
  19.             printf("Your pizza is done!\n");
  20.            
  21.             inProgress = false;
  22.         } else {
  23.             const unsigned int elapsedTimeMinutes = (const unsigned int)difftime(time(NULL), startTime) / 60;
  24.             const unsigned int elapsedTimeSeconds = (const unsigned int)difftime(time(NULL), startTime) - (elapsedTimeMinutes * 60);
  25.            
  26.             printf("Elapsed Time: %dm %ds\n", elapsedTimeMinutes, elapsedTimeSeconds);
  27.         }
  28.     }
  29.    
  30.     return 0;
  31. }
  32.  
  33. void clearConsole(const unsigned int clearHeight) {
  34.     for(unsigned int i = 0; i < clearHeight; i++) {
  35.         printf("\n");
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement