Page 1 of 1

How to parse integer from wide char string?

Posted: Sun Sep 01, 2024 2:59 pm
by mitras1
.

Re: How to parse integer from wide char string?

Posted: Sun Sep 01, 2024 8:50 pm
by CuteAlien
STL has some function in <string> like stoi or others in <cwchar> like wcstoll. Irrlicht has no tool function for wchar_t I think - so you'd have to convert to char first.

Re: How to parse integer from wide char string?

Posted: Mon Sep 02, 2024 6:32 am
by mitras1
After a little of bit experimentation I concluded that I have different kind of problem. I need access the string from editBox in EventReceiver , but it seems that it cause segfault.
Here's the my code:

Code: Select all

gui::IGUIElement* startMenu = event.GUIEvent.Caller->getParent();

gui::IGUIEditBox* widthEdit = (gui::IGUIEditBox*) startMenu->getElementFromId(-2);
gui::IGUIEditBox* heightEdit = (gui::IGUIEditBox*) startMenu->getElementFromId(-3);

wprintf(widthEdit->getText());

startMenu->setVisible(false);

Re: How to parse integer from wide char string?

Posted: Mon Sep 02, 2024 10:34 am
by CuteAlien
Sorry, not enough information. Check the pointers. Make sure the ID's are correct. Is that element really a IGUIEditBox?
You can also see all that in the debugger, just set a breakpoint and step through (if you ware not familiar with a debugger yet, take the chance to learn it, it's simply to use and you'll need it all the time when programming).

Re: How to parse integer from wide char string?

Posted: Mon Sep 02, 2024 10:58 am
by mitras1
CuteAlien wrote: Mon Sep 02, 2024 10:34 am Make sure the ID's are correct.
Yup, I accidentally set ID of the first editbox to -1. Thanks!