C++中time函数如何用
就是一打开控制台应用程序,可以自动显示目前时间
[解决办法]
控制台程序的话。你需要输出出来。
我给你段我写过的示例代码:
- C/C++ code
SYSTEMTIME CurrentTime; memset(¤t, 0, sizeof(current)); GetLocalTime(&CurrentTime); current.tm_isdst = 0; current.tm_year = CurrentTime.wYear - STARTDATE; current.tm_mon = CurrentTime.wMonth - 1; current.tm_mday = CurrentTime.wDay; current.tm_hour = CurrentTime.wHour; current.tm_min = CurrentTime.wMinute; current.tm_sec = CurrentTime.wSecond;
[解决办法]
- C/C++ code
/* ctime example */#include <stdio.h>#include <time.h>int main (){ time_t rawtime; time ( &rawtime ); printf ( "The current local time is: %s", ctime (&rawtime) ); return 0;}