Advertisement
ItachiSan

Simple C clock DevC++-friendly

Oct 2nd, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <time.h>
  5.      
  6. int main()
  7. {
  8. // Hours, minutes and seconds
  9. int hh;
  10. int mm;
  11. int ss;
  12.  
  13. // Rise and shine, Mr. Clock
  14. hh = 0;
  15. mm = 0;
  16. ss = 0;
  17.  
  18. // A clock always works
  19. while (1) {
  20.         while(hh < 24)  {
  21.         while(mm < 60)  {
  22.             while(ss < 60)  {
  23.             sleep(1);
  24.             ss++;
  25.            
  26.             // What time is it?
  27.             printf("%d : %d : %d \t\t Close with Ctrl+C \r", hh, mm, ss);
  28.             }
  29.         mm++;
  30.         ss = 0;
  31.         }
  32.         hh++;
  33.         mm = 0;
  34.         }
  35.     hh = 0;
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement