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 can Extract String ?

How can Extract String ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorial
7 Posts 5 Posters 1 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
    Le rner
    wrote on last edited by
    #1

    Hi all, I have any string in given format:: "string1-string2 string3" i want to fetch string1 that is comes before sign "-",so please tell me how can i do this? is solve when i use findstring function. please help me. if possible please explain with example. thanks in advance.

    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

    _ M 2 Replies Last reply
    0
    • L Le rner

      Hi all, I have any string in given format:: "string1-string2 string3" i want to fetch string1 that is comes before sign "-",so please tell me how can i do this? is solve when i use findstring function. please help me. if possible please explain with example. thanks in advance.

      IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

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

      CString::Tokenize

       // Example with CAtlString from MSDN
      CAtlString str( "%First Second#Third" );
      CAtlString resToken;
      int curPos= 0;
      
      resToken= str.Tokenize("% #",curPos);
      while (resToken != "")
      {
         printf("Resulting token: %s\n", resToken);
         resToken= str.Tokenize("% #",curPos);
      };
      

      By the way don't you have MSDN installed?:confused:

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

      T 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        CString::Tokenize

         // Example with CAtlString from MSDN
        CAtlString str( "%First Second#Third" );
        CAtlString resToken;
        int curPos= 0;
        
        resToken= str.Tokenize("% #",curPos);
        while (resToken != "")
        {
           printf("Resulting token: %s\n", resToken);
           resToken= str.Tokenize("% #",curPos);
        };
        

        By the way don't you have MSDN installed?:confused:

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

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

        _AnShUmAn_ wrote:

        By the way don't you have MSDN installed?

        why installed ? it is online, and I doubt the poster writes here by telepathy... ;P

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

        _ 1 Reply Last reply
        0
        • T toxcct

          _AnShUmAn_ wrote:

          By the way don't you have MSDN installed?

          why installed ? it is online, and I doubt the poster writes here by telepathy... ;P

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

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

          The MSDN site may be blocked :laugh: LOL

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

          T 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            The MSDN site may be blocked :laugh: LOL

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

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

            bahhh, ask google !

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

            1 Reply Last reply
            0
            • L Le rner

              Hi all, I have any string in given format:: "string1-string2 string3" i want to fetch string1 that is comes before sign "-",so please tell me how can i do this? is solve when i use findstring function. please help me. if possible please explain with example. thanks in advance.

              IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

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

              If you're not using a string class, there's always _tcstok()

              --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ "That's what's great about doing user interface work. No matter what you do, people will say that what you did was idiotic." -- Raymond Chen

              J 1 Reply Last reply
              0
              • M Michael Dunn

                If you're not using a string class, there's always _tcstok()

                --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ "That's what's great about doing user interface work. No matter what you do, people will say that what you did was idiotic." -- Raymond Chen

                J Offline
                J Offline
                Jerry Jeremiah
                wrote on last edited by
                #7

                or sscanf() ... He did say the string always had the exact same format ...

                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