Hello friends welcome to our new fresh blog. This blog contains the source code of Digital Clock you can simply copy this code and run it. You can run this code in .c and .cpp extention
--SOURCE CODE--
// DIGITAL WATCH //
#include<graphics.h>
#include<ctime>
#include<sstream>
#include<iomanip>
using namespace std;
int main()
{
initwindow(600,400,"Digital Watch",150,100);
while(1)
{
time_t now = time(0);
tm *ltm =localtime(&now);
stringstream t;
char time[10];
t<<setw(2)<<setfill('0')<<ltm->tm_hour<<':'
<<setw(2)<<setfill('0')<<ltm->tm_min<<':'
<<setw(2)<<setfill('0')<<ltm->tm_sec;
t>>time;
stringstream date;
date<<setw(2)<<setfill('0')<<ltm->tm_mday<<'/' // day indexing from 1
<<setw(2)<<setfill('0')<<1+ltm->tm_mon<<'/' // month indexing from 0
<<1900+ltm->tm_year;
char d[20];
date>>d;
setcolor(LIGHTGREEN);
settextstyle(1,HORIZ_DIR,8);
outtextxy(55,120,time);
settextstyle(1,HORIZ_DIR,2);
outtextxy(220,220,d);
delay(1000);
cleardevice();
}
getch();
closegraph();
}
Post a Comment