C++编程!!!!,,

来源:百度知道 编辑:UC知道 时间:2024/07/07 12:54:51
请问各位大侠,,用C++怎么获取系统运行时间(语句。),,
谢谢!~!

#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t ltime;
char tmpbuf[128];

//方法1:分别获取当前时间,日期
/* Display operating system-style date and time. */
_strtime( tmpbuf );
printf( "OS time:\\t\\t\\t\\t%s\\n", tmpbuf ); //打印当前时间
_strdate( tmpbuf );
printf( "OS date:\\t\\t\\t\\t%s\\n", tmpbuf ); //打印当前日期

//方法二:获取当前时间日期
time(<ime); //获取从1970至今经过的秒数
cout << ctime(<ime) << endl; //折算成当前时间日期
return 0;
}

VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime // address of system time structure
);

#include "Stdio.h"
#include "window.h"

void main()
{
SYSTEMTIME st;
GetSystemTime(&st);
printf("%d-%d-%d %d:%d:%d\n",st.wYear, st.wMonth, st.wD