You have to allocate a native buffer for the characters by using the Marshall StringToHGlobalAnsi method. This method allocates and fills a native memory buffer with a null terminated ANSI string initialized from a managed string.
Then you can copy this data to something like a STL string. Finally, free the allocated native buffer with a call to Marshall::FreeHGlobal.
BTW, The System::Runtime::InteropServices::Marshal static class contains a lot of methods useful for interoperability between managed and native world. For example, pointers, data buffers, strings, errors, COM stuff, memory allocations etc.
using namespace std;
using namespace System;
static void ConvertManagedStringToStdString(std::string &outStr, String ^str)
IntPtr ansiStr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str);
outStr = (const char*)ansiStr.ToPointer(); System::Runtime::InteropServices::Marshal::FreeHGlobal(ansiStr);
int main(array<System::String ^> ^args)
System::String^ myManagedString = "My test string";
cout << myStr;
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"