#include#include using namespace std; int main() { string str = "The quick brown fox jumps over the lazy dog"; string subStr = "fox"; int pos = str.find(subStr); if(pos != string::npos) cout << "The substring found at position: " << pos << endl; else cout << "The substring not found" << endl; return 0; }
#includeThe cpp string find function is part of the C++ STL (Standard Template Library) package.#include using namespace std; int main() { string str; cout << "Enter a string: "; getline(cin, str); string subStr = "hello"; int pos = str.find(subStr); if(pos != string::npos) cout << "The substring found at position: " << pos << endl; else cout << "The substring not found" << endl; return 0; }