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. Parsing a CString.

Parsing a CString.

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelp
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.
  • P Offline
    P Offline
    phanindra varma
    wrote on last edited by
    #1

    hi... I have a CString like CString str ="1,2,3,4,5,6"; now i want to retrieve each one as string like str1=1; str2=2; str3=3; here "," is delimeter. Even this is so simple... but i am not familier with CString methods. please help me in this regard Thanks in advance.... Regards varma.

    R _ 2 Replies Last reply
    0
    • P phanindra varma

      hi... I have a CString like CString str ="1,2,3,4,5,6"; now i want to retrieve each one as string like str1=1; str2=2; str3=3; here "," is delimeter. Even this is so simple... but i am not familier with CString methods. please help me in this regard Thanks in advance.... Regards varma.

      R Offline
      R Offline
      Rane
      wrote on last edited by
      #2

      Use AfxExtractSubString function! Regards, Rane

      1 Reply Last reply
      0
      • P phanindra varma

        hi... I have a CString like CString str ="1,2,3,4,5,6"; now i want to retrieve each one as string like str1=1; str2=2; str3=3; here "," is delimeter. Even this is so simple... but i am not familier with CString methods. please help me in this regard Thanks in advance.... Regards varma.

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        See CString::Tokenize

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        S 1 Reply Last reply
        0
        • _ _AnsHUMAN_

          See CString::Tokenize

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          S Offline
          S Offline
          santhoshv84
          wrote on last edited by
          #4

          Hi, you can do like this.

          CString out = "1,2,3,4,5,6";
          out.Replace(\_T(","), \_T(""));
          int len = out.GetLength();
          for(int i=0;i<len;i++)>
          {
          	String\[i\] = out.Mid(i,1);
          	AfxMessageBox(String\[i\]);
          }
          

          The price of anything is the amount of life you exchange for it. Thanks and Regards. SANTHOSH V

          P 1 Reply Last reply
          0
          • S santhoshv84

            Hi, you can do like this.

            CString out = "1,2,3,4,5,6";
            out.Replace(\_T(","), \_T(""));
            int len = out.GetLength();
            for(int i=0;i<len;i++)>
            {
            	String\[i\] = out.Mid(i,1);
            	AfxMessageBox(String\[i\]);
            }
            

            The price of anything is the amount of life you exchange for it. Thanks and Regards. SANTHOSH V

            P Offline
            P Offline
            phanindra varma
            wrote on last edited by
            #5

            Thanks.... But i have Two digit nubers also..... like CString out={"1,10,345"}; then how to do... :doh: Thanks in advance varma

            T 1 Reply Last reply
            0
            • P phanindra varma

              Thanks.... But i have Two digit nubers also..... like CString out={"1,10,345"}; then how to do... :doh: Thanks in advance varma

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

              as ever replied, use CString::Tokenize()[^]

              [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

              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