Click to See Complete Forum and Search --> : Boyer-Moore-Horspool implementation


donfredi
December 2nd, 2005, 08:24 PM
Hi everyone,
I am trying to implement the BMH algorithm but the following function is not working. Any ideas or code listings would be appreciated

int table[10];
void shiftTable(char* pattern, int num){
int i;
num= strlen(pattern);
for(i=0;i<10;i++)
table[i]=num;
for(int j=0; j<pNum; j++)
table[pattern[j]]=num-(1+j); //what I am trying to do here is to
//put (num-1-j) into table using the position of pattern[j] as index i.e, for //pattern="BOY", num = 3 and table[0] should have 2 (num-1-j);
}

The code compiles fines, but the program hangs when the function above is called. Please help me out