转自 http://support.microsoft.com/kb/311259
使用的第二种方法
注意在头文件中#include <msclr/marshal.h>
另外 using namespace System::Runtime::InteropServices;
System::String * str = S"Hello world/n";
char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str);
printf(str2);
Marshal::FreeHGlobal(str2);
第一种方法 说是 __pin 是老语法,需要在编译时加上一个选项,
故弃而不用。
第三种方法没有试。