my code is not returning anything.
#include<bits/stdc++.h>
using namespace std;
#define Max_N 10005
int reset[Max_N];
void kmppreprocess(string pat)
{
int i;
while( i<pat.size())
{
int i=0,j=-1;
reset[0]=-1;
while(j>=0&&pat[i]!=pat[j])
{
j=reset[j];
}
i++;j++;
reset[i]=j;
}
}
void kmp(string str,string pat)
{
kmppreprocess(pat);
int i=0,j=0;
while( i<str.size())
{
while(j>=0 && str[i]!=pat[j])
{
j=reset[j];
}
i++;
j++;
reset[i]=j;
}
if(j==pat.size())
{
cout<<"pattern found at:"<<i-j<<endl;
j=reset[j];
}
}
int main()
{
string str=“abaabcxabcxabxa”;
string pat=“abcxabx”;
for(int i=0;i<Max_N;i++)
{
reset[i]=-1;
}
kmp(str,pat);
return 0;
}