Results 1 to 3 of 3

Thread: Double to String

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Double to String

    I want to convert a double to a string. I've seen many posts on this, however, I want to convert it to a string.h string, not a char array string.

    Is this possible and if so, how?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    nevermind. I used _gcvt to convert it to char, then converted it to string.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You mean string string not string.h string

    A useful way:
    Code:
    ostringstream oss;
    oss << double_variable;
    
    string mystr = oss.str(); // can use oss.str() direct if you want
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width