How to parse integer from wide char string?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mitras1
Posts: 26
Joined: Mon Jan 29, 2024 8:02 am

How to parse integer from wide char string?

Post by mitras1 »

.
CuteAlien
Admin
Posts: 9733
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to parse integer from wide char string?

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mitras1
Posts: 26
Joined: Mon Jan 29, 2024 8:02 am

Re: How to parse integer from wide char string?

Post 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);
CuteAlien
Admin
Posts: 9733
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to parse integer from wide char string?

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mitras1
Posts: 26
Joined: Mon Jan 29, 2024 8:02 am

Re: How to parse integer from wide char string?

Post 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!
Post Reply