Platform::String from cxx to std::string and const char

Recently I do a lot of Cxx code for Windows Store App. At first I would avoid Cxx as much as I can, but at some point (especially when accessing windows API) I must use it.

Cxx has Platform::String but I’m not sure what is the main different with std::string, you can check it here. You can easily make get value from Platform::String for your std::string , here it is

Platform::String ^myPatString = "Hurrah";
std::string myStdString(myPatString->Begin(),myPatString->End());  // Platform::String to std::string
const char* myCharString = myStdString->c_str(); // std::string to const char

Easy peasy

2 thoughts on “Platform::String from cxx to std::string and const char

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s