Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. string strToSplit = "splitting strings, in|multiple ways";
  2. std::vector<std::string> words;
  3. boost::split(words, strToSplit, boost::is_any_of("\t ,|"));
  4. std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
  5.  
  6. words.clear();
  7. std::istringstream iss(strToSplit);
  8. std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(), std::back_inserter(words));
  9. std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement