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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Double to String

Double to String

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
4 Posts 4 Posters 0 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.
  • M Offline
    M Offline
    Max
    wrote on last edited by
    #1

    I use function _gcvt() for convert the double value to string such as: y = 0.01; _gcvt(y,10,buffer); MessageBox(buffer); My problem is that the MessageBox will show "1.e-002". How to do if want the string "0.01" after finish this function.

    G J H 3 Replies Last reply
    0
    • M Max

      I use function _gcvt() for convert the double value to string such as: y = 0.01; _gcvt(y,10,buffer); MessageBox(buffer); My problem is that the MessageBox will show "1.e-002". How to do if want the string "0.01" after finish this function.

      G Offline
      G Offline
      Greg Daye
      wrote on last edited by
      #2

      you could try doing a sprintf. y = 0.01; sprintf ( buffer, "%f", y );

      1 Reply Last reply
      0
      • M Max

        I use function _gcvt() for convert the double value to string such as: y = 0.01; _gcvt(y,10,buffer); MessageBox(buffer); My problem is that the MessageBox will show "1.e-002". How to do if want the string "0.01" after finish this function.

        J Offline
        J Offline
        Jun Du
        wrote on last edited by
        #3

        Use

        sprintf(buffer, "%f8.2", y);

        instead. Best, Jun

        1 Reply Last reply
        0
        • M Max

          I use function _gcvt() for convert the double value to string such as: y = 0.01; _gcvt(y,10,buffer); MessageBox(buffer); My problem is that the MessageBox will show "1.e-002". How to do if want the string "0.01" after finish this function.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          or see here double y = 1230.01; CString strxx; strxx.Format("%lf", y ); MessageBox(strxx);_**


          **_

          whitesky


          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