Quick actions

cmd+k|ctrl+k

Navigation

Languages

std::string / Finding characters in a string / Essential C++

Snippet info

Language

Cpp

Visibility

public

Author

kkowalczyk

Created

2019-03-27T06:54:39Z

Updated

2019-03-27T06:54:39Z

#include <iostream>
#include <string>

using namespace std;
 
int main() {
    std::string str = "Curiosity killed the cat";
    auto it = str.find("cat");
    
    if (it != std::string::npos)
        std::cout << "Found at position: " << it << '\n';
    else
        std::cout << "Not found!\n";
}
INFO