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. real simple question

real simple question

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    ok this is vexing me i have a string like this: blahblahblahblah$blahblahblahblah$ notice is contains $ characters. i want to SPLIT this string using the $ as a delimiter. The string is stored in a CString (i'm using MFC). Can someone show me how I can tokenize this string. A SIMPLE example please!!! ARGH, thanks!!

    A M 2 Replies Last reply
    0
    • L Lost User

      ok this is vexing me i have a string like this: blahblahblahblah$blahblahblahblah$ notice is contains $ characters. i want to SPLIT this string using the $ as a delimiter. The string is stored in a CString (i'm using MFC). Can someone show me how I can tokenize this string. A SIMPLE example please!!! ARGH, thanks!!

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      CString buff("This is$my string");

      for(int x=0; x<

      Notice this only splits a string in half nothing more. It find the first $ character and copies anything left of it to a buffer and anything right of it to another buffer.

      It would reauire a littel tweaking to split a string multiple times.

      Cheers!

      p.s-Ignore the << it should only be one...but I don't know the excape code in HTML for single angle brackets. Sorry!

      "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

      1 Reply Last reply
      0
      • L Lost User

        ok this is vexing me i have a string like this: blahblahblahblah$blahblahblahblah$ notice is contains $ characters. i want to SPLIT this string using the $ as a delimiter. The string is stored in a CString (i'm using MFC). Can someone show me how I can tokenize this string. A SIMPLE example please!!! ARGH, thanks!!

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Use the undocumented function AfxExtractSubString().

        int n = 0;
        CString sToken;

        while ( AfxExtractSubString ( sToken, sBlahBlahString, n++, '$' ))
        {
        // do stuff with the token ...
        }

        --Mike-- Best score on the mini-putt game: 26 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan and Jamie Salé.

        L A T 3 Replies Last reply
        0
        • M Michael Dunn

          Use the undocumented function AfxExtractSubString().

          int n = 0;
          CString sToken;

          while ( AfxExtractSubString ( sToken, sBlahBlahString, n++, '$' ))
          {
          // do stuff with the token ...
          }

          --Mike-- Best score on the mini-putt game: 26 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan and Jamie Salé.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          omg thanks been looking for a simple way like that!!!!

          1 Reply Last reply
          0
          • M Michael Dunn

            Use the undocumented function AfxExtractSubString().

            int n = 0;
            CString sToken;

            while ( AfxExtractSubString ( sToken, sBlahBlahString, n++, '$' ))
            {
            // do stuff with the token ...
            }

            --Mike-- Best score on the mini-putt game: 26 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan and Jamie Salé.

            A Offline
            A Offline
            alex barylski
            wrote on last edited by
            #5

            Cool...that is easy! Thanx Mike! "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

            1 Reply Last reply
            0
            • M Michael Dunn

              Use the undocumented function AfxExtractSubString().

              int n = 0;
              CString sToken;

              while ( AfxExtractSubString ( sToken, sBlahBlahString, n++, '$' ))
              {
              // do stuff with the token ...
              }

              --Mike-- Best score on the mini-putt game: 26 My really out-of-date homepage Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan and Jamie Salé.

              T Offline
              T Offline
              Todd Harvey
              wrote on last edited by
              #6

              I wish we could rate these posts like you can at CodeGuru - what a helpful post!:laugh:

              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