Skip to main content
gamedev.net
🔒 Locked

TextOut

Started by laurence900 Apr 20, 2003 at 2:26 PM 1 replies 350+ views
Original Post
laurence900
laurence900
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
evillive2
evillive2
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.
Evillive2

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.