https://docs.microsoft.com/en-us/cpp/dotnet/how-to-convert-system-string-to-standard-string?view=vs-2019
StringToHGlobalAnsi方法可以把托管 String^对象的内容复制到本机堆,
然后将它转换为 (ANSI) 格式。此方法会分配所需的本机堆内存:
//using namespace System::Runtime::InteropServices; char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(str); printf(str2); Marshal::FreeHGlobal( IntPtr(str2) );
原文地址:https://www.cnblogs.com/sinceret/p/11360330.html
时间: 2024-10-10 22:15:15