Jump to content
  • Advertisement
Sign in to follow this  
ecr0n

TextOut()

This topic is 5464 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
Advertisement
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
Thats the radix (base). 10 = base 10 (decimal). You can use it to output in binary if you set the radix to 2, or hex if you set it to 16, and so on.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!