当前位置: 代码迷 >> VC >> System:String 转 std下的string解决办法
  详细解决方案

System:String 转 std下的string解决办法

热度:2740   发布时间:2013-02-25 00:00:00.0
System::String 转 std下的string
System::String 转 std下的string
String* str = "dd";
string str2 = "";
如何把str中的"dd"赋值到str2中??

------解决方案--------------------------------------------------------
String* str = "dd";
string str2 = reinterpret_cast<char*>(System::Runtime::InteropServices::Marshal::StringToCoTaskMemAnsi(str).ToPointer());
------解决方案--------------------------------------------------------
C/C++ code
std::string ConvertToString(System::String^ str){ int q=(int)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str); char* p=(char*)q; return std::string(p);}
  相关解决方案