From 64ac62ffae69880f5135b687040b703243b0ff25 Mon Sep 17 00:00:00 2001 From: Narendra <75013042+nkrider7@users.noreply.github.com> Date: Sat, 7 Oct 2023 21:28:06 +0530 Subject: [PATCH] Create findsubstring.cpp --- findsubstring.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 findsubstring.cpp diff --git a/findsubstring.cpp b/findsubstring.cpp new file mode 100644 index 0000000..de99f3f --- /dev/null +++ b/findsubstring.cpp @@ -0,0 +1,22 @@ +#include +#include +using namespace std; + +int main() +{ +string str = "kala chor kali juban"; +string str1 = "chor"; + + +size_t found = str.find(str1); +if (found != string::npos) + cout << "First occurrence is " << + found << endl; + +char arr[] = "geeks"; +found = str.find(arr, found+1); +if (found != string::npos) + cout << "Next occurrence is " << + found << endl; +return 0; +}