#include<stdio.h> #include<graphics.h> #include<time.h> int gd=DETECT,gm,x,y; void main() { time_t now; struct tm *timeinfo; initgraph(&gd,&gm,"..\\BGI\\"); x=getmaxx()/2-80; y=getmaxy()/2-20; while(!kbhit()) { time(&now); timeinfo=localtime(&now); printf("%2d : %2d : %2d",timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); delay(1000); cleardevice(); } getch(); }
Search This Blog
Digital Clock C Program
This is a c program to display a digital clock showing correct time. It reads time at 1 second interval and displays it on the screen. To know how to get date and time in C, see this post: How to Get Time and Date in C - C Program to Read and Display Time and Date
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment