.cpp头文件中需包括
using namespace System; //String^库文件
using namespace System::Runtime::InteropServices; //Marchal库文件
函数内容
char* c = "adsfdasf";
String^ strd = gcnew String(c);
char* d = (char*)(void*)Marshal::StringToHGlobalAnsi(strd);
cout << d << endl;
转换为char*之后便可以进行后续的处理
Ps: using namespace System; 出现问题须在
项目-属性-配置属性-常规-公共语言运行时支持
改为 ” 公共语言运行时支持(/clr)“
转载:https://blog.csdn.net/weixin_44640149/article/details/109227888?spm=1001.2014.3001.5502