急求!wstring 怎么转成TCHAR* 类型!!!

2025-02-26 03:56:43
推荐回答(2个)
回答1:

这样应该可以
wstring ws;
......
TCHAR* t = (TCHAR*)(&ws[0]);
楼主试试看。
#include
#include
using namespace std;
int main()
{
string s;
wstring ws;
ws = L"OK";
TCHAR *tc = (TCHAR *)(&ws[0]);

return 0;
}
测试没有报错。

祝你好运!

回答2:

const TCHAR *t = ws.c_str();