首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++中time函数怎么用

2012-07-25 
C++中time函数如何用就是一打开控制台应用程序,可以自动显示目前时间[解决办法]控制台程序的话。你需要输出

C++中time函数如何用
就是一打开控制台应用程序,可以自动显示目前时间


[解决办法]
控制台程序的话。你需要输出出来。

我给你段我写过的示例代码:

C/C++ code
        SYSTEMTIME CurrentTime;        memset(&current, 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;} 

热点排行