In this code:
this->_label = CCLabelTTF::labelWithString(number,"Artial", 32);
number
is 5, but must be a const char *
.
How can I convert number
from an int
to the required const char *
?
The only three-argument call listed here is:
+ (id) labelWithString: (NSString *) string
fontName: (NSString *) name
fontSize: (CGFloat) size
That means number
should not be an int
but should indeed be a const char *
.
If you want to populate it with the string "5"
instead of the integer 5
, you'll need to convert it to a string first.
Depending on the language you're using, this could be something like:
char buffer[20];
sprintf (buffer, "%d", number);
(for C) or using something like stringstreams in C++.