C Program to display current date

This program can be used to set or change the system time

#include
#include

int main(void)
{
struct time t;
gettime(&t);
printf(“The current hour is: %dn”, t.ti_hour);
printf(“The current min is: %dn”, t.ti_min);
printf(“The current second is: %dn”, t.ti_sec);

/* Add one to the hour,minute & sec struct element and then call settime */

t.ti_hour++;
t.ti_min++;
t.ti_sec++;
settime(&t);
printf(“The current hour is: %dn”, t.ti_hour);
printf(“The current min is: %dn”, t.ti_min);
printf(“The current second is: %dn”, t.ti_sec);
return 0;
}

Read Users' Comments (0)

0 Response to "C Program to display current date"

Post a Comment