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. C / C++ / MFC
  3. Converting

Converting

Scheduled Pinned Locked Moved C / C++ / MFC
6 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.
  • D Offline
    D Offline
    Drake Elsari
    wrote on last edited by
    #1

    How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()

    E A I 3 Replies Last reply
    0
    • D Drake Elsari

      How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()

      E Offline
      E Offline
      Erik Thompson
      wrote on last edited by
      #2

      CString myCString("1N3"); char* MyStringPointer = (LPCTSTR)myCString; isdigit(MyStringPointer[0]); // true isdigit(((LPCTSTR)myCString)[1]); // false isdigit(myCstring.GetAt(2)); // true If you want to be ansi/unicode agnostic then use _istdigit. Endless ways. -Erik

      D 1 Reply Last reply
      0
      • E Erik Thompson

        CString myCString("1N3"); char* MyStringPointer = (LPCTSTR)myCString; isdigit(MyStringPointer[0]); // true isdigit(((LPCTSTR)myCString)[1]); // false isdigit(myCstring.GetAt(2)); // true If you want to be ansi/unicode agnostic then use _istdigit. Endless ways. -Erik

        D Offline
        D Offline
        Drake Elsari
        wrote on last edited by
        #3

        none of those worked on my VCPP, and I have the 3rd service pack. It says cannot convert const char* to char*.

        E 1 Reply Last reply
        0
        • D Drake Elsari

          none of those worked on my VCPP, and I have the 3rd service pack. It says cannot convert const char* to char*.

          E Offline
          E Offline
          Erik Thompson
          wrote on last edited by
          #4

          Drake, It's best to learn C/C++ before trying to program in MFC. Since all you are doing is checking is digit and not modifying the string, you can put const in front of your char* declaration and the compiler will not complain. const char* strPtr = (LPCTSTR)myCString; -Erik

          1 Reply Last reply
          0
          • D Drake Elsari

            How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()

            A Offline
            A Offline
            AlexMarbus
            wrote on last edited by
            #5

            See CString::GetBuffer(..). Be sure to call ReleaseBuffer when you're done. -- Alex Marbus www.marbus.net But then again, I could be wrong.

            1 Reply Last reply
            0
            • D Drake Elsari

              How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()

              I Offline
              I Offline
              Ivan Yap
              wrote on last edited by
              #6

              Hee now than i saw your message.. prev, I got the same problem with the isDigit() function so I got :mad: and create a iIsNum(CString string) function using VC++ ver 6 BOOL iIsNum(CString string) { int strLenght = string.GetLength(); bool _isnum; CString chr; for (int i = 0; i < strLenght ; i++) { chr = string.Mid(i,1); if(chr >= "0" && chr <= "9") _isnum = TRUE; else { _isnum = FALSE; break; // no use search for other char } } return _isnum; } Hope you still can use this function ~~~

              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