string.format help

J

java

I am java programmer thrust into the world of c++, wasn't that
competant in java to begin with so things just got harder. I have a
float that comes out of a database and I want to change it (to a
string) so that it is formatted to be say instead og 230000.00 to be
$230,000 Got told to use string.format but can't seem to find any
expressions that will allow me to format the string the way I want.
Any help will be appreciated.
 
F

feel_energetic

the best choice in c++ is boost::literal_cast<>
and the c-style sprintf() is an alternative approach
 
F

feel_energetic

the best choice in c++ is boost::literal_cast<>
and the c-style sprintf() is an alternative approach
 
R

red floyd

java said:
Thanks for your help I ended up using FloatToStrF with ffCurrency.

Glad your program worked, but neither of those (FloatToStrF nor
ffCurrency) are Standard C++. They are part of some third party library.

Just so you'll know.
 
I

Ian Collins

java said:
I am java programmer thrust into the world of c++, wasn't that
competant in java to begin with so things just got harder. I have a
float that comes out of a database and I want to change it (to a
string) so that it is formatted to be say instead og 230000.00 to be
$230,000 Got told to use string.format but can't seem to find any
expressions that will allow me to format the string the way I want.
Any help will be appreciated.
Read up on stringstreams.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

string.format 0
Help 1
Code help please 4
Help for a newbie 13
I need help with sfml on Codeblocks! 0
Help with my responsive home page 2
Need Help on String.Format() method 8
Help with Loop 0

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top