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. LPTSTR to float

LPTSTR to float

Scheduled Pinned Locked Moved C / C++ / MFC
c++
12 Posts 6 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.
  • P paper67

    I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done. Thx.

    C Offline
    C Offline
    Cool Ju
    wrote on last edited by
    #2

    Hi Use _tstof() Bye, Cool Ju :cool: Dream Ur Destiny

    P 1 Reply Last reply
    0
    • P paper67

      I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done. Thx.

      U Offline
      U Offline
      User 1586251
      wrote on last edited by
      #3

      try using atof function

      P 1 Reply Last reply
      0
      • C Cool Ju

        Hi Use _tstof() Bye, Cool Ju :cool: Dream Ur Destiny

        P Offline
        P Offline
        paper67
        wrote on last edited by
        #4

        _tstof() doesn't work. C:\Projects\PCnt\XLConvDlg.cpp(835) : error C2065: '_tstof' : undeclared identifier Thx

        C 1 Reply Last reply
        0
        • U User 1586251

          try using atof function

          P Offline
          P Offline
          paper67
          wrote on last edited by
          #5

          Yes, but I want to use a character neutral set function. Thx

          1 Reply Last reply
          0
          • P paper67

            _tstof() doesn't work. C:\Projects\PCnt\XLConvDlg.cpp(835) : error C2065: '_tstof' : undeclared identifier Thx

            C Offline
            C Offline
            Cool Ju
            wrote on last edited by
            #6

            Hi, Add math.h and stdlib.h Bye, Cool Ju :cool: Dream Ur Destiny

            P 1 Reply Last reply
            0
            • C Cool Ju

              Hi, Add math.h and stdlib.h Bye, Cool Ju :cool: Dream Ur Destiny

              P Offline
              P Offline
              paper67
              wrote on last edited by
              #7

              Doesn't work. Same error.

              1 Reply Last reply
              0
              • P paper67

                I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done. Thx.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #8

                paper67 wrote:

                Is there any way to convert from a LPTSTR to a float value.

                what about _tcstod function

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV -- modified at 6:54 Tuesday 6th December, 2005

                P 1 Reply Last reply
                0
                • P paper67

                  I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done. Thx.

                  B Offline
                  B Offline
                  Bob Ciora
                  wrote on last edited by
                  #9

                  How about the old standby, sscanf? There is also a wide-character version, swscanf. If you've eliminated the whitespace around the string-represented floating-point value, then the following will work:

                  // input: CString sData

                  float fValue;

                  // sscanf will return the number of items pulled out of the string
                  int nResult = sscanf((LPCTSTR)sData, "%f", &fValue);
                  if( nResult != 1 )
                  {
                  // Didn't find a floating-point value. Take corrective action...
                  }

                  Bob Ciora

                  1 Reply Last reply
                  0
                  • P paper67

                    I am using VC 6.0. I am writing an MFC application where I use strings with the _T("") macro.(Character set neutral). Is there any way to convert from a LPTSTR to a float value. I noticed that the function _ttof does not exist in VC 6.0. Does anybody know how this conversion can be done. Thx.

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #10

                    wcstod() contained in <stdlib.h> ~RaGE();

                    1 Reply Last reply
                    0
                    • T ThatsAlok

                      paper67 wrote:

                      Is there any way to convert from a LPTSTR to a float value.

                      what about _tcstod function

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV -- modified at 6:54 Tuesday 6th December, 2005

                      P Offline
                      P Offline
                      paper67
                      wrote on last edited by
                      #11

                      That's the one I need. Thx a lot.

                      T 1 Reply Last reply
                      0
                      • P paper67

                        That's the one I need. Thx a lot.

                        T Offline
                        T Offline
                        ThatsAlok
                        wrote on last edited by
                        #12

                        paper67 wrote:

                        Thx a lot.

                        My Pleasure

                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                        cheers, Alok Gupta VC Forum Q&A :- I/ IV

                        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