fork download
  1. #include <string>
  2. #include <iostream>
  3. int main()
  4. {
  5. int occurrences = 0;
  6. std::string::size_type pos = 0;
  7. std::string s = "что Тест что Тест что";
  8. std::string target = "что";
  9. while ((pos = s.find(target, pos)) != std::string::npos) {
  10. ++occurrences;
  11. pos += target.length();
  12. }
  13. std::cout << occurrences << std::endl;
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 4324KB
stdin
Standard input is empty
stdout
3