int vs const char


#1

this->_label = CCLabelTTF::labelWithString(number,“Artial”, 32);

WHERE int number = 5, but must be const char

can anybody help me with this?


#2

you can convert int to a const char*, just like:
char string[32];
sprintf(string, “%d”, number);

label = CCLabelTTF::labelWithString(string,“Artial”, 32);


#3

jni/…/…/Classes/HelloWorldScene.cpp:104: error: invalid conversion from ‘char’ to ‘char**’
jni/…/…/Classes/HelloWorldScene.cpp:104: error: initializing argument 1 of ’int sprintf’
jni/…/…/Classes/HelloWorldScene.cpp:105: error: invalid conversion from ’char’ to ’const char**’


#4

it works, thanks