C++ 中 TCHAR 如何转换成std::string类型的?

看这个网址解决的:https://blog.csdn.net/weixin_34023982/article/details/87380020

可以利用W2A函数将将_TCHAR *转换为char *,举例:

#include "stdafx.h"
#include <stdlib.h>
#include <atlconv.h>  //需要加入的 1

int _tmain(int argc, _TCHAR* argv[])
{
_TCHAR * tchBuffer = L"12345";

USES_CONVERSION; //这两句也要加入2
char *szBuffer = W2A(tchBuffer);//这两句也要加入3

int nNumber = atoi(szBuffer);

printf("nNumber:%d", nNumber);

return 0;
}

找到自己程序报错的地方,将上面三句加入即可运行

原文地址:https://www.cnblogs.com/rjjhyj/p/10949428.html