Sign in to follow this  

Printing numbers in Allegro

This topic is 3717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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

This topic is 3717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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