tokenizer help
-
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! -
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! -
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
-
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!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
-
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! -
Yes thank you. Stephen Hewitt's suggestion worked out fine.