fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. template <typename SubstringType>
  5. bool substring_found(const std::string & String, const SubstringType & Substring)
  6. {
  7. return String.find(Substring) != std::string::npos;
  8. }
  9.  
  10. int main()
  11. {
  12. std::string SomeString = "test";
  13.  
  14. if (substring_found(SomeString, 'e'))
  15. std::cout << "substring 'e' found\n";
  16.  
  17. if (!substring_found(SomeString, 'a'))
  18. std::cout << "no substring 'a' found\n";
  19. }
  20.  
Success #stdin #stdout 0s 3016KB
stdin
Standard input is empty
stdout
substring 'e' found
no substring 'a' found