We're required to use gettime()
to get the current time in C. I'm trying to print the current time but the error:
error: storage size of 't' isn't known
occurs. I don't know how to solve this. Here is the code:
#include<stdio.h>
#include<dos.h>
int main(){
struct time t;
gettime(&t);
printf("%d:%d:%d", t.ti_hour,t.ti_min,t.ti_sec);
getch();
return 0;
}
The standard C function to get the local time is simply
time
, included in the header time.hExample taken from here.
More info on the different time format :
http://www.cplusplus.com/reference/ctime/mktime/
http://www.cplusplus.com/reference/ctime/localtime/