Hi, long time no C.
I have started using the Irrlicht gaming engine but have bumped into a problem which has been bugging me for the past 6 hours flat. I have a variable containing a std::string but it needs to be converted to a (const wchar_t *) string. Does anybody know how to make this string type conversion?
The code I'm using is as follows:

IGUIEditBox* player = env->addEditBox(settings["player_name"].c_str(), rect<s32>(170, 80, 320, 100));

//or alternative that could work without the variable
IGUIEditBox* player = env->addEditBox(L"test", rect<s32>(170, 80, 320, 100));

and in that code it is the settings["player_name"] variable which is the std::string when the input for addEditBox actually requires a (const wchar_t *) instead of std::string.

So anyone got any ideas?

6 hours? OMG next time use google! Here is how to do it.

wchar_t wname[255];
std::string name = "John";
size_t convertedChars = 0;
mbstowcs_s(&convertedChars, wname, sizeof(wname)/sizeof(wname[0]), name.c_str(), _TRUNCATE);

IGUIEditBox* player = env->addEditBox(wname, rect<s32>(170, 80, 320, 100));
Life saver

Wow, thank you. That is exactly what I needed and yet my hours of googling didn't find that link. Thankyou very much. If I could give you double rep points I would.

This question has already been answered. Start a new discussion instead.