Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

laurence900

TextOut

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

Ok hears the story. Im making a war game for me and my brothers and i need some help. You enter the main window and its got a window with a menu and then the word Money. Now what i need to do is this. I need a varible called Money whitch i can add and substract to and from. Eg Money - 200 Build some tanks Money - 500 I tried using this int Money; hdc = GetDC(hwnd); //Set the colors TextOut(hdc,SCREENWIDTH/2,30,"Money - ",strlen("Money - ")); TextOut(hdc,SCREENWIDTH/2+3,30,Money,strlen(Money)); It says cannot convert int to const char or something any one help me out ? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
TextOut(hdc,SCREENWIDTH/2+3,30,Money,strlen(Money));

TextOut writes TEXT to the screen, Money is an integer. You have to convert Money into a string first. atoi() works for that or you could get the whole thing done using sprintf and one call to TextOut.

char buffer[32];

sprintf( buffer, "Money - %d", Money );
TextOut(hdc,SCREENWIDTH/2,30,buffer,strlen(buffer));


1 call to TextOut without having to fiddle with making sure the words and numbers line up.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!