64,666
社区成员
发帖
与我相关
我的任务
分享
//我4楼贴的是从LPTSTR 转到string;这个是从string转成LPTSTR ,运行环境:vc6
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main(int argc, CHAR* argv[])
{
string str="dddd";
LPTSTR lp=const_cast<char*>(str.c_str());
cout<<lp<<endl;
system("pause");
return 0;
}
//这么写
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main(int argc, CHAR* argv[])
{
LPTSTR lp="ddd";
string str=(string)lp;
cout<<str<<endl;
system("pause");
return 0;
}