fork(6) download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <sstream>
  4. #include <algorithm>
  5.  
  6. int main()
  7. {
  8.  
  9. std::size_t kk;
  10. std::string word="spoo";
  11. std::string sentence="seven spoons tables";
  12.  
  13.  
  14.  
  15. for(auto word: {"spoo", "spoons", "tab", "tables", "seven"} )
  16. {
  17. std::stringstream ss(sentence) ;
  18. std::istream_iterator<std::string> f ;
  19. auto it =std::find_if( std::istream_iterator<std::string> (ss),
  20. f,
  21. [=](const std::string& str){
  22. return str == word;
  23. }
  24. );
  25.  
  26. if(it != f )
  27. std::cout << "Success for " << word << std::endl;
  28.  
  29. }
  30. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Success for spoons
Success for tables
Success for seven