Originally Posted by
swoopy
I think it would be something like:
Code:
String gc = IPTextBox->Text();
string my_string = (const char*) Marshall::StringToHGlobalAnsi(gc).ToPointer());
That first line may not be quite right. I can't quite tell from what ChaosEngine posted.
it really depends on which version of visual studio you're using. if it's vs2003 then it's
Code:
String* gc = textbox->get_Text();
string my_string = (const char*) Marshall::StringToHGlobalAnsi(gc).ToPointer());
if it's vs2005 textbox->text is a property not a method os it's
Code:
String^ gc = textbox->Text;
string my_string = (const char*) Marshall::StringToHGlobalAnsi(gc).ToPointer());
actually reading the docs again you're supposed to free the memory you get back
so the code should be (assuming vs2005)
Code:
String^ gc = textbox->Text;
IntPtr textPtr = Marshall::StringToHGlobalAnsi(gc);
string my_string = (const char*) textPtr .ToPointer());
Marshall::FreeHGlobal(textPtr)
there will also be some security issues calling this.