#include <stdio.h>
#include <string.h>
int bf ( char longstr[] , char shortstr[] )
{
int m = strlen(longstr);
int n = strlen(shortstr);
int i = 0 ;
int j = 0 ;
while (i<m && j<n)
{
if (longstr[i] == shortstr[j])
{
i++ ;
j++ ;
}
else
{
i = i - j + 1 ;
j = 0 ;
}
}
if (j>=n)
{
return (i-n) ;
}
else
{
return -1 ;
}
}
int main ()
{
char str[] = "abcdcfgkeababcde" ;
int pos = bf(str,"bcde");
printf("%d\n",pos);
return 0 ;
}