Converting float to String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adeel.e@gmail.com

    #1

    Converting float to String

    hiz .. i've got to convert a float to a string .. how is that possible
    ... i tired using .toString but got error saying cudnt find it .. i
    think i've missed an include somewhere .. any suggestions ?

  • Sumit Rajan

    #2
    Re: Converting float to String


    <adeel.e@gmail. com> wrote in message
    news:1132853155 .240067.29220@g 49g2000cwa.goog legroups.com...[color=blue]
    > hiz .. i've got to convert a float to a string .. how is that possible
    > .. i tired using .toString but got error saying cudnt find it .. i
    > think i've missed an include somewhere .. any suggestions ?
    >[/color]

    Yes. Read the FAQ:


    Regards,
    Sumit.
    --
    Sumit Rajan <sumitr@msdc.hc ltech.com>


    Comment

    • Chris Theis

      #3
      Re: Converting float to String

      <adeel.e@gmail. com> wrote in message
      news:1132853155 .240067.29220@g 49g2000cwa.goog legroups.com...[color=blue]
      > hiz .. i've got to convert a float to a string .. how is that possible
      > .. i tired using .toString but got error saying cudnt find it .. i
      > think i've missed an include somewhere .. any suggestions ?
      >[/color]

      You can convert the float via an ostringstream.

      std::ostringstr eam os;
      os << 1.5343;
      string Test = os.str();

      Cheers
      Chris



      Comment

      • skyhawk

        #4
        Re: Converting float to String

        What about this:

        std::stringstre am ss;
        float f;
        std::string s;

        ss << f;
        ss >> s;

        Comment

        Working...