c++中获取系统时间问题
#include <time.h>
#include <iostream>
using namespace std;
int main( void )
{
int year;
time_t t = time(0);
char tmp[64];
strftime( tmp, sizeof(tmp), "%Y",localtime(&t) );
year=tmp;
cout<<year<<endl;
//puts( tmp );
return 0;
}
请问一下怎样将获取的时间进行调用
[解决办法]
//
TDateTime dt = TDateTime().CurrentDateTime();
AnsiString strCurrDt = dt.FormatString("yyyy-mm-dd hh:nn");
inline void _MyOutputDbgString(char* lpDbgInfo)
{
char lpOutMsg[_DEBUG_BUFFER_SIZE_] = {0x00};
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
sprintf(lpOutMsg,"[%d:%d:%d.%d]:%s\r\n",sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds,lpDbgInfo);
printf(lpOutMsg);
OutputDebugString(lpOutMsg);
}