Jump to content
  • Advertisement
Sign in to follow this  
SonicD007

Why is TextOut() doing this?

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

pongtextouterror.png At first I thought the problem was the string not having a null terminating character at the end but I made a console app and did everything the same except the output was using cout instead of TextOut. I tried debugging it but the value of s was "0" so I'm not sure what the problem is. C++ windows api visual studio 2008 prof ed
void ScoreDisplay(HDC hdc, RECT* prc)
{
	
	std::stringstream ss;
	ss << g_iScore[0];
	std::string s(ss.str());
	
	SetBkColor(hdc, RGB(0, 0, 0));
	SetTextColor(hdc, RGB(255,0,0));
	TextOut(hdc, 200, 100, s.c_str(), 100);
}

g_iScore[0] has the value of 0. It's an int.

Share this post


Link to post
Share on other sites
Advertisement
What is the TextOut function?

It looks like you are using stringstream and string correctly. The display acts like s.c_str() is not NULL-terminated, but it should be since c_str() is supposed to automatically append a NULL character at the end.


EDIT: nevermind... Antheus beat me with facts =(

-me

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!