Time functions
To display system time on the screen function used are:
gettime() : to fetch the system time
settime() : to set the system time
Structure of the time as used by these functions:
struct time
{
unsigned char ti_min; minutes
unsigned char ti_hour; hours
unsigned char ti_hund; hundredths of seconds
unsigned char ti_sec; seconds
};
/* Program developed in Turboc3 */ #include<conio.h> #include <stdio.h> #include <dos.h> void main() { struct time t; int a,b,c; clrscr(); gettime(&t); printf("The current time is: %2d:%02d:%02d.%02d\n", t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); getch(); }
/* Program developed in Turboc3 */ /* to display running time */ #include<conio.h> #include <stdio.h> #include <dos.h> void main() { struct time t; clrscr(); while(!kbhit()) { gotoxy(10,10); gettime(&t); printf("The current time is: %2d:%02d:%02d.%02d\n", t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); printf("\n\n\n"); printf("The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec); } getch(); }