CStdString str = "Hello World"; int pos = str.Find("World"); if (pos != -1) { std::cout << "Found at position " << pos; }
CStdString str = "The quick brown fox"; int pos = str.Find("jumped"); if (pos == -1) { std::cout << "Not found"; }In this example, we create a CStdString object with the value "The quick brown fox". Then we use the Find method to search for the substring "jumped" in the string. Since the substring is not found, we print a message stating that it is not found. Package library: MFC Library (Microsoft Foundation Classes)