Sign in to follow this  

TextOut()

This topic is 4824 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

y0 I'm using C++ and am wanting to output the score of player one and player two. The players each have their own class and in the class is the declaration "int score;" and in the constructor it's set to 0. I want to know how i could display their score with the TextOut() function? I know how to output strings and the like but outputting integers? and what about a string and an integer?...

Share this post


Link to post
Share on other sites
You can only output a string. If you want an integer or anything else, you need to make it into a string first. For example:

char szBuffer[256];
int nScore = 42;
sprintf(szBuffer,"Player One: %d points",nScore);
TextOut(hDC,0,0,szBuffer,strlen(szBuffer));


Share this post


Link to post
Share on other sites
Use a function called:
itoa

Do something like,

char buffer[80];
int score = 24;
itoa(score, buffer, 10);

Look up the function in MSDN for reference

-prowst

Share this post


Link to post
Share on other sites

This topic is 4824 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