Skip to main content
GameDev.net gamedev.net
🔒 Locked

TextOut problem Help. win32.

Started by kyuss Mar 16, 2005 at 12:46 AM 1 replies 800+ views
Original Post
kyuss
kyuss
Does anyone know how to use TextOut to display an int in the client area. Do i have to convert an int to a TCHAR? if so how? BOOL TextOut( HDC hdc, // handle to DC int nXStart, // x-coordinate of starting position int nYStart, // y-coordinate of starting position LPCTSTR lpString, // character string int cbString // number of characters ); thats the function all I want to do is Display the following text: "10 Green Bottles Sitting on the Wall If the wind began to blow There would be 9 Green bottles sitting on the wall" you press a key, and the count goes down by 1, until there are no bottles. I'm just learning, so only reply if you can help. Help is very much appreciated.
Endurion
Endurion
You need to convert the int into a string or char array.

Easiest:

char szTemp[260];

wsprintf( szTemp, "%d bottles of wheat beverage on the wall, %d to go", iBottles, iBottlesToGo );

The %d will be replaced by an int.


Alternatively you can use std::string and stringstream.

std::stringstream strStream;

strStream << iBottles << " bottles of wheat beverage on the wall, " << iBottlesToGo << " to go";

To get the result as const char* you call strStream.str().c_str();
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Topic Locked

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

Sign in to reply to this topic.