fork download
  1. #include <iostream>
  2. #include <boost/tokenizer.hpp>
  3. #include <vector>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string s("ABC__, ,DEF,HIJ");
  10. typedef boost::char_separator<char> char_separator;
  11. typedef boost::tokenizer<char_separator> tokenizer;
  12.  
  13. char_separator comma(",");
  14. tokenizer token(s, comma);
  15. tokenizer::iterator it;
  16.  
  17. vector<string> strings;
  18.  
  19. for(it = token.begin(); it != token.end(); it++)
  20. {
  21. //cout << (*it).c_str() << endl;
  22. strings.push_back((*it));
  23. }
  24.  
  25. std::vector<string>::iterator iv;
  26. for(iv = strings.begin(); iv != strings.end(); iv++)
  27. {
  28. cout << *iv << endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 3236KB
stdin
Standard input is empty
stdout
ABC__
 
DEF
HIJ