C Program To Display Digital Clock
Learn How To Display Digital Clock in C Programming Language. This digital clock will display the current time with real time updates of time.
This C Program makes use of a System Library File which has its header as time.h. The time.h header file defines Two Macro, Four Variable Types and various other functions for manipulating time and date.
Must Read: System Shutdown C Program For Linux Ubuntu
C Program To Display Digital Clock (Live Clock)
time_t ts, flag = 1;
struct tm *ct;
printf("\n\n\n\tActive Digital Clock\n\t");
ts = time(NULL);
ct = localtime(&ts);
if(flag || ct -> tm_min % 59 == 0)
printf("%02d:%02d:%02d", ct -> tm_hour, ct -> tm_min, ct -> tm_sec);
flag = 0;
if(ct -> tm_sec % 59 == 0)
printf("%02d:", ct -> tm_min);
printf("%02d", ct ->tm_sec);
Must Read: C Program To Print System Date and Time
If you have any compilation error or doubts in this C Program To Display Active Digital Clock, let us know about it in the Comment Section below.
Thanks. This program code for printing live clock works perfectly fine. Can we actually make a program to display only static time?
Yes. There are so many built in methods in C Libraries to display static time and date. You will get it on google.
Sir how i get contact no.
Sir could you give me link please.
Can u please explain This:
flag || ct