Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. convert double to string?

convert double to string?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sunnygirl
    wrote on last edited by
    #1

    hello @all, how can i convert a double value into a string? can anybody help me??? thank you very much! sunny

    L R J 3 Replies Last reply
    0
    • S Sunnygirl

      hello @all, how can i convert a double value into a string? can anybody help me??? thank you very much! sunny

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      With this function I think _gcvt(); Convert double number to string; store string in buffer

      1 Reply Last reply
      0
      • S Sunnygirl

        hello @all, how can i convert a double value into a string? can anybody help me??? thank you very much! sunny

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        Try using sprintf (or _stprintf to support UNICODE as well):

        char buf[16];
        sprintf(buf, "%f", doubleValue);
        TCHAR tbuf[16];
        _stprintf(buf, _T("%f"), doubleValue); // This is the recommended one

        If you're using MFC, you can do this:

        CString str;
        str.Format(_T("%f"), doubleValue);

        Hope this helps, Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
        Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

        1 Reply Last reply
        0
        • S Sunnygirl

          hello @all, how can i convert a double value into a string? can anybody help me??? thank you very much! sunny

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #4

          sprintf() [EDIT] Ryan answered the question while I had the thread open. He has a very good answer. [/EDIT] John

          R 1 Reply Last reply
          0
          • J John M Drescher

            sprintf() [EDIT] Ryan answered the question while I had the thread open. He has a very good answer. [/EDIT] John

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #5

            John M. Drescher wrote: answered the question while I had the thread open Don't you hate it when that happens ;) Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
            Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

            J 1 Reply Last reply
            0
            • R Ryan Binns

              John M. Drescher wrote: answered the question while I had the thread open Don't you hate it when that happens ;) Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
              Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

              J Offline
              J Offline
              John M Drescher
              wrote on last edited by
              #6

              This was the first time I noticed it. John

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups