#include <time.h>
#include <stdio.h>
int main()
{
time_t nowtime = time(NULL);
tm *now = localtime(&nowtime);
printf("now: %04d-%02d-%02d %02d:%02d:%02d\nunix time: %ld\n",
now->tm_year+1900, now->tm_mon+1, now->tm_mday,
now->tm_hour, now->tm_min, now->tm_sec, (long)nowtime);
return 0;
}
推荐阅读:
C++ 隐式类类型转化 Implicit Class-Type Conversions
《C语言从入门到精通》.(王娣,韩旭 ).[PDF] + DVD视频光盘文件