Page 1 of 1

convert C8 to INT

Posted: Tue Aug 21, 2007 12:38 am
by Neji[Ger]
how can i convert C8 to INT

Posted: Tue Aug 21, 2007 2:56 am
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

Posted: Wed Aug 22, 2007 3:24 pm
by Neji[Ger]
and c8* in wchar_t?

Posted: Wed Aug 22, 2007 4:05 pm
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);

Posted: Wed Aug 22, 2007 4:11 pm
by hybrid
If you want to avoid c type handling you can do core::stringw(c_string_pointer).c_str()

Posted: Fri Oct 12, 2007 5:55 pm
by Neji[Ger]
and const wchar_t * to c8*?

Posted: Fri Oct 12, 2007 7:13 pm
by shogun
Search for "wcstomb".