convert C8 to INT

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
Neji[Ger]
Posts: 5
Joined: Tue Aug 21, 2007 12:36 am

convert C8 to INT

Post by Neji[Ger] »

how can i convert C8 to INT
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The conversion from c8 [or char as the rest of the world calls it] to int is implicit. You don't need to do anything.

Code: Select all

c8 byte = 10;
int quad = byte;
If, on the other hand, you want to know how convert from a character string [c8* or c8[]] to integer, there are several ways. You could use the C library functions for type conversion atoi(), strtol() even sscanf().

Irrlicht also has a function strtol10() in fast_atof.h that you could use also, but it only works for unsigned values.

Travis
Neji[Ger]
Posts: 5
Joined: Tue Aug 21, 2007 12:36 am

Post by Neji[Ger] »

and c8* in wchar_t?
Soory for my BAD english!

STNE
Dark Pirates
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

i think there's a function called swprintf which you could use to do that. Either way if you google converting char* to wchar_t* then you'll find out, or google swprintf to see if i'm right about that.

You'd use it something like this:

c8 cstr[5];
wchar_t wstr[50];
swprintf(wstr, 50, "%s", cstr);
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you want to avoid c type handling you can do core::stringw(c_string_pointer).c_str()
Neji[Ger]
Posts: 5
Joined: Tue Aug 21, 2007 12:36 am

Post by Neji[Ger] »

and const wchar_t * to c8*?
Soory for my BAD english!

STNE
Dark Pirates
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Search for "wcstomb".
Post Reply