TCHAR szFileTime[100];
SYSTEMTIME systime;
memset(&systime, 0, sizeof(SYSTEMTIME));
GetSystemTime(&systime);
_stprintf(szFileTime, _T("%d-%d-%d %.2d:%.2d:%.2d"), systime.wYear, systime.wMonth, systime.wDay, systime.wHour, systime.wMinute, systime.wSecond);string s = string(szFileTime);//这里怎么转?outFile<<setw(100)<<string;程序中想以string方式输出文件,现在将数据用 tchar[]数组存储好,请问如何把tchar数组转化为string,用来输出?
SYSTEMTIME systime;
memset(&systime, 0, sizeof(SYSTEMTIME));
GetSystemTime(&systime);
_stprintf(szFileTime, _T("%d-%d-%d %.2d:%.2d:%.2d"), systime.wYear, systime.wMonth, systime.wDay, systime.wHour, systime.wMinute, systime.wSecond);string s = string(szFileTime);//这里怎么转?outFile<<setw(100)<<string;程序中想以string方式输出文件,现在将数据用 tchar[]数组存储好,请问如何把tchar数组转化为string,用来输出?
解决方案 »
- 已知鼠标滑过的关键点,如何构造一个平滑的弧线
- 关于网页信息收集
- 一个很奇怪的问题
- SetWindowPos会使按钮获得焦点的问题
- SQL 查询器 错误提示 ?在线等哈!
- 请大家帮忙解决我的难题呀!在线等!分不够还有!
- 如何获取CPU的温度、主板风扇转速等系统监视信息??
- 网吧刷卡收费系统的开发
- 今天我生日,1700分大放送,为增加节日气氛,出一题C++题目给20分,内容不限先到先得。
- 一个数据库查询中的奇怪问题:
- winpcap抓包过滤网址URL
- fatal error C1010: unexpected end of file while looking for precompiled header d
{
return WideCharToMultiByte (CP_ACP, 0, szU, -1, szA, cnt, NULL, NULL) ;
}
int A2U(const char* szA,wchar_t* szU,size_t cnt)
{
return MultiByteToWideChar (CP_ACP, 0, szA, -1, szU, cnt) ;
}
std::string U2A(const wchar_t* szU)
{
int nRetCode=U2A(szU,0,0);
if(0==nRetCode)
return std::string();
std::string str(nRetCode-1,'\0');
U2A(szU,(char*)(str.c_str()),nRetCode);
return str;
}
std::wstring A2U(const char* szA)
{
int nRetCode=A2U(szA,0,0);
if(0==nRetCode)
return std::wstring();
std::wstring str(nRetCode-1,'\0');
A2U(szA,(wchar_t*)(str.c_str()),nRetCode);
return str;
}
如下调用:
string s;
if(sizeof(TCHAR)==sizeof(char))
s = szFileTime;
else
s = U2A(szFileTime);