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. tokenizer help

tokenizer help

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcomsysadminquestion
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.
  • D Offline
    D Offline
    dellthinker
    wrote on last edited by
    #1

    Hi all. Im trying to break a server message up into segments. So i figured i could use strtok(). Problem is the sockets i have setup are defined to STL string for C++ so i cant use strtok() obviously. So i found a tokenizer from this site. But i cant seem to use it for my socket project properly. The message looks like this: :user.client computer1 sysinfo :sync1 smtp.startup Instead of processing the entire server message, im trying to get the last two words after the last colon (i.e. sync1 smtp.startup) Note: I got the tokenizer from this url: http://www.codeproject.com/cpp/stringtok.asp Any suggestions? Thanx in advance!

    N S D 3 Replies Last reply
    0
    • D dellthinker

      Hi all. Im trying to break a server message up into segments. So i figured i could use strtok(). Problem is the sockets i have setup are defined to STL string for C++ so i cant use strtok() obviously. So i found a tokenizer from this site. But i cant seem to use it for my socket project properly. The message looks like this: :user.client computer1 sysinfo :sync1 smtp.startup Instead of processing the entire server message, im trying to get the last two words after the last colon (i.e. sync1 smtp.startup) Note: I got the tokenizer from this url: http://www.codeproject.com/cpp/stringtok.asp Any suggestions? Thanx in advance!

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #2

      Why don't you take a look at Boost Tokenizer[^]?


      Programming Blog utf8-cpp

      D 1 Reply Last reply
      0
      • N Nemanja Trifunovic

        Why don't you take a look at Boost Tokenizer[^]?


        Programming Blog utf8-cpp

        D Offline
        D Offline
        dellthinker
        wrote on last edited by
        #3

        Thanx for the suggestion, I would try it but i cant seem to find the download link for boost/tokenizer.hpp EDIT: Never mind, found it :P

        1 Reply Last reply
        0
        • D dellthinker

          Hi all. Im trying to break a server message up into segments. So i figured i could use strtok(). Problem is the sockets i have setup are defined to STL string for C++ so i cant use strtok() obviously. So i found a tokenizer from this site. But i cant seem to use it for my socket project properly. The message looks like this: :user.client computer1 sysinfo :sync1 smtp.startup Instead of processing the entire server message, im trying to get the last two words after the last colon (i.e. sync1 smtp.startup) Note: I got the tokenizer from this url: http://www.codeproject.com/cpp/stringtok.asp Any suggestions? Thanx in advance!

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Why not simply use something like this: --------------------------------------- // Console.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include using namespace std; void main() { string message = ":user.client computer1 sysinfo :sync1 smtp.startup"; istringstream iss(message); string pt1, pt2, pt3, pt4, pt5; iss >> pt1 >> pt2 >> pt3 >> pt4 >> pt5; cout << "pt1 = " << pt1 << endl; cout << "pt2 = " << pt2 << endl; cout << "pt3 = " << pt3 << endl; cout << "pt4 = " << pt4 << endl; cout << "pt5 = " << pt5 << endl; } Steve

          1 Reply Last reply
          0
          • D dellthinker

            Hi all. Im trying to break a server message up into segments. So i figured i could use strtok(). Problem is the sockets i have setup are defined to STL string for C++ so i cant use strtok() obviously. So i found a tokenizer from this site. But i cant seem to use it for my socket project properly. The message looks like this: :user.client computer1 sysinfo :sync1 smtp.startup Instead of processing the entire server message, im trying to get the last two words after the last colon (i.e. sync1 smtp.startup) Note: I got the tokenizer from this url: http://www.codeproject.com/cpp/stringtok.asp Any suggestions? Thanx in advance!

            D Offline
            D Offline
            DQNOK
            wrote on last edited by
            #5

            Did you solve your problem yet?

            D 1 Reply Last reply
            0
            • D DQNOK

              Did you solve your problem yet?

              D Offline
              D Offline
              dellthinker
              wrote on last edited by
              #6

              Yes thank you. Stephen Hewitt's suggestion worked out fine.

              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