Sign in to follow this  
pi_man

Printing numbers in Allegro

Recommended Posts

pi_man    100
i've been having a bit of trouble with printing numbers in Allegro. At the moment i am using the textout_ex() function and replacing the string with a variable holding the number of lives the player has left, problem being it says "invalid conversion from `int' to `const char*'" Any help would be great.

Share this post


Link to post
Share on other sites
SiCrane    11839
You need to convert the number to a string. Assuming C++, you can use a std::stringstream or boost::lexical_cast. Ex:

std::stringstream sstr;
sstr << my_number;
const char * my_number_as_char_pointer = sstr.str().c_str()

Share this post


Link to post
Share on other sites
konForce    592
The textprintf_ex() function provides printf style formatting, so doing any of your own conversion is a wasted effort.


int player_score;

textprintf_ex(screen, font, 10, 10, makecol(255, 100, 200), -1, "Score: %d", player_score);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this