Jump to content
  • Advertisement

Archived

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

MessageBox

<string> formatting

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

I''ve recently started using for string operations and am finding it much better than the old C-style. Just one thing though, are there any functions for formatting C++ strings with integers, floats, etc...., the equivalent of the sprintf() function?

Share this post


Link to post
Share on other sites
Advertisement
Yes, look for the stringstream library!

However, the std::string class contains a myString.printf() function too, I think..

----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. The who understand binary and those who don''t"

Share this post


Link to post
Share on other sites
Hello MessageBox,

there dec, hex, and oct iomanipulators that will set stream to out these.
There is setw set the width of a field
setprecision set number of nuber after .
setfill set what to fill spaces with.

ex float test=234.5678;
cerr << setw(10) << setprecision(2) << setfill(: ) << test << endl;
gaves
::::234.57 as an output. I belive it round up on percision but not sure.

Lord Bart

opps it took the : ) as a simliy face

[edited by - lord bart on September 22, 2003 9:10:28 AM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!