Skip to main content
added C++11 version
Source Link
Ferruccio
  • 101.1k
  • 38
  • 232
  • 305

The Boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH (stringconst string& t, tokens) {   cout << t << "." << endl; } } 

Updated for C++11:

#include <iostream> #include <string> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int, char**) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer<char_separator<char>> tokens(text, sep); for (const auto& t : tokens) { cout << t << "." << endl; } } 

The Boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH(string t, tokens) { cout << t << "." << endl; } } 

The Boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int, char**) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH (const string& t, tokens) {   cout << t << "." << endl; } } 

Updated for C++11:

#include <iostream> #include <string> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int, char**) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer<char_separator<char>> tokens(text, sep); for (const auto& t : tokens) { cout << t << "." << endl; } } 
added 8 characters in body
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

The boostBoost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) {   string text = "token, test string";   char_separator<char> sep(", ");   tokenizer< char_separator<char> > tokens(text, sep);   BOOST_FOREACH(string t, tokens)   {   cout << t << "." << endl;   } } 

The boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH(string t, tokens) { cout << t << "." << endl; } } 

The Boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) {   string text = "token, test string";   char_separator<char> sep(", ");   tokenizer< char_separator<char> > tokens(text, sep);   BOOST_FOREACH(string t, tokens)   {   cout << t << "." << endl;   } } 
added 2 characters in body
Source Link
user405725
user405725

The boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer<char_separator<char>>tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH(string t, tokens) { cout << t << "." << endl; } } 

The boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer<char_separator<char>> tokens(text, sep); BOOST_FOREACH(string t, tokens) { cout << t << "." << endl; } } 

The boost tokenizer class can make this sort of thing quite simple:

#include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main(int argc, char** argv) { string text = "token, test string"; char_separator<char> sep(", "); tokenizer< char_separator<char> > tokens(text, sep); BOOST_FOREACH(string t, tokens) { cout << t << "." << endl; } } 
added link
Source Link
Ferruccio
  • 101.1k
  • 38
  • 232
  • 305
Loading
added 1 characters in body
Source Link
Ferruccio
  • 101.1k
  • 38
  • 232
  • 305
Loading
Source Link
Ferruccio
  • 101.1k
  • 38
  • 232
  • 305
Loading