有天需要写获取当前时间,并打印出来,弄了半天才搞定,因此先写到这里,下次需要就可以直接使用了.:)
#include
#include
main()
{
time_t t;
struct tm *tm_t;
char* strtime;
time(&t);
tm_t=localtime(&t);
printf("the current time is: %02d:%02d:%02d
",tm_t->tm_hour,tm_t->tm_min,tm_t->tm_sec);
return 0;
}
注:如果想获得国际标准时间,只需将localtime换成gmtime函数就可以。