There are mentioned conversions between System::String and const char* in this article.
My question is: Is it possible to make conversion from System::String to char*(note on missing const) with this construction(marshal_context)?
And if not what is recommended solution of this problem?
Am I forced to use older Marshal::StringToHGlobalAnsi?
There is also additional question in comments.
You can obtain the underlying c-style string by using
c_str(), a method provided by Strings. It’sconst, but you can just copy it away into your own, variablechar*.Just allocate a buffer big enough, like you would with
malloc, and thenstrncpyinto it. There’s a hundred different ways of doing this, but it all boils down to reserve memory, copy the string, have fun with it.