fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <boost/algorithm/string/classification.hpp> // Include boost::for is_any_of
  6. #include <boost/algorithm/string/split.hpp> // Include for boost::split
  7. using namespace std;
  8.  
  9. int main() {
  10. std::string s = "as for whether when";
  11. std::vector<std::string> words;
  12. boost::split(words, s, boost::is_any_of(" "), boost::token_compress_on);
  13. // Sorting the int vector
  14. sort(words.begin(), words.end());
  15. for(string &this_s : words) std::cout << this_s << " ";
  16. return 0;
  17. }
Success #stdin #stdout 0s 3484KB
stdin
Standard input is empty
stdout
as for when whether