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());
[解决办法]
std::string ConvertToString(System::String^ str){ int q=(int)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str); char* p=(char*)q; return std::string(p);}