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. How to split the CString variable in MFC?(Very Urgent..............)

How to split the CString variable in MFC?(Very Urgent..............)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
6 Posts 5 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.
  • A Offline
    A Offline
    AnithaSubramani
    wrote on last edited by
    #1

    Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)

    R D G 3 Replies Last reply
    0
    • A AnithaSubramani

      Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      CString::Tokenize() ? For urgent purposes, you can try TokenizeUrgnz().

      It is a crappy thing, but it's life -^ Carlo Pallini

      C 1 Reply Last reply
      0
      • A AnithaSubramani

        Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        You can use AfxExtractSubString().

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        1 Reply Last reply
        0
        • R Rajesh R Subramanian

          CString::Tokenize() ? For urgent purposes, you can try TokenizeUrgnz().

          It is a crappy thing, but it's life -^ Carlo Pallini

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Welcome in the CP's Memorable Quotes [^], man! :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          R 1 Reply Last reply
          0
          • C CPallini

            Welcome in the CP's Memorable Quotes [^], man! :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Thank you. Now, *that* is a honor. :-O It took me a while to make it to the list though. :rolleyes:

            It is a crappy thing, but it's life -^ Carlo Pallini

            1 Reply Last reply
            0
            • A AnithaSubramani

              Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)

              G Offline
              G Offline
              Gustavo Ferreira
              wrote on last edited by
              #6

              Hi Anitha, You can use this code: void CSplit::Split(CString str, CString separator, CStringArray& array) { CString aux; int pos; pos = 0; array.RemoveAll(); for (int i=0; i<str.getlength();> { if (str[i]==separator) { aux = str.Mid(pos,(i-pos)); pos = i+1; array.Add(aux); } } aux = str.Mid(pos,str.GetLength()-pos); array.Add(aux); } Regards, Gustavo

              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