#include#include using namespace std; int main() { int i,j,temp; char str[100]={"This is a pattern matching"}; char substr[20]={"pattern"}; for(i=0;str[i]!='';i++) { j=0; if(str[i]==substr[j]) { temp=i+1; while(str[i]==substr[j]) { i++; j++; } if(substr[j]=='') { cout<<"The substring is present in given string at position "<
C++ Program to Find Substring in String (Pattern Matching)
Levels of difficulty: medium / perform operation:
- C++ Program to Compare Two Strings Without Using Pointers
- C++ Program to convert first letter of each word of a string to uppercase and other to lowercase
- C++ Program to Find Substring in String (Pattern Matching)
- C++ Program to Remove Spaces From String
- C++ Program to Compare Two Strings Using Pointers
- C++ program to check the entered character is capital letter, small letter, digit or a special character