Jump to content
  • Advertisement
Sign in to follow this  
rgibson11

variables in a string

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

Hello, I am having some problems with displaying a font on a screen, I am using opengl with OGLFT library which uses freetype font system. It displays const char * values like "Hello" perfectly, but I need it to display for example the fps, like this FPS : (float variable here) I looked for ways to transfer numbers to strings but no luck. stringstream doesn't seem to work either. if anyone please could give me some info if you ran into this problem before, thanks,

Share this post


Link to post
Share on other sites
Advertisement
std::stringstream ss;
std::string s;

ss << fps;
ss >> s;

yourfunction( s.c_str() );
or if you're lazy
yourfunction( ss.str().c_str() );
or if you're very lazy
yourfunction( boost::lexical_cast<whateveryouwant>( fps ) );

Share this post


Link to post
Share on other sites
Quote:
Original post by rgibson11
I looked for ways to transfer numbers to strings but no luck. stringstream doesn't seem to work either.
In what way does stringstream not work? It is the accepted way of performing this operation.

Share this post


Link to post
Share on other sites
Thanks a lot Rewdew, that solved it!
I have no idea but I was doing things very similar to your code but it just wasn't showing up. I guess its just due to me being fairly new to stringstreams

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.

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!