string.format help

Discussion in 'C++' started by java, Jan 20, 2006.

  1. java

    java Guest

    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.
    java, Jan 20, 2006
    #1
    1. Advertising

  2. the best choice in c++ is boost::literal_cast<>
    and the c-style sprintf() is an alternative approach
    feel_energetic, Jan 20, 2006
    #2
    1. Advertising

  3. the best choice in c++ is boost::literal_cast<>
    and the c-style sprintf() is an alternative approach
    feel_energetic, Jan 20, 2006
    #3
  4. java

    java Guest

    Thanks for your help I ended up using FloatToStrF with ffCurrency.
    java, Jan 20, 2006
    #4
  5. java

    red floyd Guest

    java <> c++ wrote:
    > 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.
    red floyd, Jan 20, 2006
    #5
  6. java

    Ian Collins Guest

    java <> c++ wrote:
    > 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.

    --
    Ian Collins.
    Ian Collins, Jan 20, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,149
    Janaka
    Feb 18, 2004
  2. ankur
    Replies:
    1
    Views:
    12,704
    Jan =?UTF-8?B?VGhvbcOk?=
    Aug 27, 2007
  3. Chris Angelico
    Replies:
    3
    Views:
    144
    Mark Lawrence
    Mar 1, 2013
  4. Peter Otten
    Replies:
    0
    Views:
    125
    Peter Otten
    Feb 28, 2013
  5. Rick Johnson
    Replies:
    0
    Views:
    132
    Rick Johnson
    Feb 28, 2013
Loading...

Share This Page