






















System::String^ to std::string
void MarshalString ( System::String^ s, std::string& os )
{
using namespace System::Runtime::InteropServices;
const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
std::string to System::String^
string s="aaaaaaaaaaa";
String^ str=gcnew String(s.c_str());
char * to System::String^
char *ch="this is char pointer";
String^ str=gcnew String(ch);// 或 :System::Runtime::InteropServices::Marshal::PtrToStringAnsi((IntPtr)ch);
std::string to char *
string str="hello";
char * ch;
ch=str;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。