Program of Pattern Matching
Program of Pattern Matching
#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
int match,i,j,k=0;
if(strlen(pattern)>strlen(text))
return 0;
for(i=0;i<strlen(text);i++)
k=0;
for(j=i;k<strlen(pattern);j++,k++)
if(pattern[k]!=text[j])
match=0;
break;
else
match=1;
}
if(match==1)
return (i+1);
return 0;
main()
char text[25],pattern[25];
int posi;
clrscr();
gets(text);
gets(pattern);
posi=match(text,pattern);
if(posi==0)
else
cout<<pattern<<"start at "<<posi;
getch();