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 separate a string to several parts?

How to separate a string to several parts?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestion
6 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.
  • F Offline
    F Offline
    freehawk
    wrote on last edited by
    #1

    Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

    M T D G G 5 Replies Last reply
    0
    • F freehawk

      Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

      M Offline
      M Offline
      Monty2
      wrote on last edited by
      #2

      going by memory here try strtok i can't even remember what my point is now, but anyway, i'm correct Barring unforeseen acts of God and Adminstrators, my server will be up tomorrow. I'm more worried about the Adminstrators.

      1 Reply Last reply
      0
      • F freehawk

        Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        you've got a function which synopsis is the following

        CString CString::Mid(int nFirst, int nCount) const;

        nFirst is the position of the first char you want to extract (pos 0 for the first of the string), nCount is the number of chars you want. look at the MSDN CString Class Members for more details


        TOXCCT >>> GEII power

        1 Reply Last reply
        0
        • F freehawk

          Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

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

          See if AfxExtractSubString() is of any help.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          1 Reply Last reply
          0
          • F freehawk

            Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

            G Offline
            G Offline
            George L Jackson
            wrote on last edited by
            #5

            Use CString.Tokenize into split separate strings, and use CString.AppendFormat("\"%s\"", ...) and CString.Apend(",") to build the new string.

            1 Reply Last reply
            0
            • F freehawk

              Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk

              G Offline
              G Offline
              GermanGeorge
              wrote on last edited by
              #6

              UpdateData(TRUE); CString erg[20]; int a,b,z; z=0; a=0; for(;;) { b=m_text.Find(" ",a); if(b<0) { erg[z]=m_text.Mid(a,m_text.GetLength()-a); break; } erg[z]=m_text.Mid(a,b-a); a=b; a++; z++; }

              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