System String and Std String Conversation

Mar 20, 2014 at 4:43pm
i have a std string variable in which i want to enter system string^ value..
how to do it? how to convert?

example:

string a;
String^ b;

a = b; // its error since it cannot convert from System String^ to std string.

im trying:
a = Convert::ToString(b);

but im getting
error while trying to match the argument list '(std::string, System::String ^)'
Last edited on Mar 20, 2014 at 4:46pm
Mar 20, 2014 at 4:53pm
What is this System::String?

----------
If you manage to obtain a null-terminated char array you can construct a std::string from that.
Mar 20, 2014 at 4:56pm
You'll have to do some more fancy marshaling than that to get a System::String into an std::string. I found some possible answers here:
http://stackoverflow.com/questions/946813/c-cli-converting-from-systemstring-to-stdstring

@maeriden
I'm assuming he's doing .NET interop, which means he's using C++/CLI instead of pure C++.
Mar 20, 2014 at 6:05pm
actually im doing graphic programming with C++ (GUI-forms) applications
Last edited on Mar 20, 2014 at 6:07pm
Mar 20, 2014 at 6:13pm
Yes. Windows Forms is an API included with .NET. In order to use this API with C++, you actually are using C++/CLI instead of native C++. Hence, the System namespace and the caret ^ character to signify managed pointers (instead of * used for native pointers).
Topic archived. No new replies allowed.