How to get an int out of wchar_t

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
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

How to get an int out of wchar_t

Post by Peter Müller »

Hi!
How can i cast the wchar_t string, i got with IGUIEditBox::getText() cast into an int?
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Re: How to get an int out of wchar_t

Post by Serg Nechaeff »

Peter Müller wrote:Hi!
How can i cast the wchar_t string, i got with IGUIEditBox::getText() cast into an int?
Hey, Peter! it's as simple as that:

stringc _str = yourbox->getText();
int value = atoi (_str.c_str());
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Thanks. Found something else:

int i = _wtoi(yourbox->getText());

wtoi stands for wchar to int and atoi for ascii to int, right?
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

absolutely! and it's even simpler
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Post Reply