Advertisement
ItachiSan

Simple C clock Linux-friendly

Oct 2nd, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. int main()
  6. {
  7. // Variabili
  8. int hh;
  9. int mm;
  10. int ss;
  11.  
  12. // Iniziamo dall'alba
  13. hh = 0;
  14. mm = 0;
  15. ss = 0;
  16.  
  17. // Un orologio va sempre...
  18. while (1) {
  19.         while(hh < 24)  {
  20.             while(mm < 60)  {
  21.                 while(ss < 60)  {
  22.                         printf("%d : %d : %d \tClose with Ctrl+C\r", hh, mm, ss);
  23.                         fflush(stdout);
  24.                         sleep(1);
  25.                         ss++;
  26.                     }
  27.             mm++;
  28.             ss = 0;
  29.             }
  30.         hh++;
  31.         mm = 0;
  32.         }
  33.     hh = 0;
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement