there is an header file called "dos.h" which contains predefined structures for time and date.
So i have declared here two variables of type
struct date d;
struct time t;
to get the current system date and time call function getdate() & gettime() where these functions take date , time respectively.
getdate(&d);
gettime(&t);
PredefinedStructures :
date:
struct date {
int da_year; /* current year */
char da_day; /* day of the month */
char da_mon; /* month (1 = Jan) */
};
time:
struct time {
unsigned char ti_min; /* minutes */
unsigned char ti_hour; /* hours */
unsigned char ti_hund; /* hundredths of seconds */
unsigned char ti_sec; /* seconds */
};
-------------------------------------------------------------------------------------------
#include
#include"dos.h"
#include"conio.h"
void main()
{
struct date d;
struct time t;
clrscr();
do{
getdate(&d);
gettime(&t);
gotoxy(15,11);
textcolor(YELLOW);
cprintf("***************************************");
gotoxy(15,13);
cprintf(" Digital Clock using C ");
gotoxy(15,15);
cprintf("***************************************");
textcolor(WHITE);
gotoxy(35,17);
cprintf(" by shyamala ");
gotoxy(15,19);
textcolor(YELLOW);
cprintf("***************************************");
textcolor(WHITE);
gotoxy(23,24);
cprintf("Date(dd/mm/yy) : %d/%d/%d",d.da_day,d.da_mon,d.da_year);
gotoxy(23,26);
cprintf("Time(hr/min/sec) : %d/%d/%d",t.ti_hour,t.ti_min,t.ti_sec);
gotoxy(27,30);
textcolor(RED);
cprintf("Dear User Hit Any key to Exit!!");
delay(100);
}
while(!kbhit());
}
------------------------------------------------------------------------------------------------
Keep rocking
Shyamala