1if (string1.find(string2) != std::string::npos) {
2 std::cout << "found!" << '\n';
3}
1if (s1.find(s2) != std::string::npos) {
2 std::cout << "found!" << '\n';
3}
1#include <iostream>
2#include <string>
3#include <algorithm>
4#include <functional>
5
6int main()
7{
8 std::string in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,"
9 " sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";
10 std::string needle = "pisci";
11 auto it = std::search(in.begin(), in.end(),
12 std::boyer_moore_searcher(
13 needle.begin(), needle.end()));
14 if(it != in.end())
15 std::cout << "The string " << needle << " found at offset "
16 << it - in.begin() << '\n';
17 else
18 std::cout << "The string " << needle << " not found\n";
19}