Implement Digital Clock Using C Graphics
#include <conio.h>
#include <graphics.h>
#include <time.h>
#include <dos.h>
#include <string.h>
int main() {
/* request auto detection */
int gdriver = DETECT, gmode;
int midx, midy, err;
long mytime;
char date[256];
/* initialize graphic mode */
initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
err = graphresult();
if (err != 0) {
/* error occurred */
printf("Graphics Error: %s\n",
grapherrormsg(err));
return 0;
}
/* mid positions in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* mid positions in x and y axis */
midx = getmaxx() / 2;
midy = getmaxy() / 2;
while (!kbhit()) {
/* clears graphic screen */
cleardevice();
/* get time in seconds */
mytime = time(NULL);
/* store the date and time in the given string */
strcpy(date, ctime(&mytime));
settextjustify(CENTER_TEXT, CENTER_TEXT);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
/* locate the postion to write */
moveto(midx, midy);
/* print the date and time */
outtext(date);
/* sleep for a second */
sleep(1);
}
getch();
/* deallocate memory allocated for graphic screen */
closegraph();
return 0;
}
Output: (c program to implement digital clock)
can you please help me...? I want to become a great programmer, even though Im too young.. give me a tutorial for all of your knowledge about programming.. thanks.. :)
ReplyDeleteIt has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
ReplyDeleteData Science Interview Questions
Angular JS Interview Questions
Big Data Training in Velachery
AWS Certified Developer
Best Resource of Learning Devops
Blueprism Interview Questions
Automation Anywhere Interview Questions