我找到了代码:
char *BoyerMoore_negative(char *string, int strLength)
{
char *data ="nice bad good worst";
int dataLength = strlen(data) - 1;
int skipTable[256], i;
char *search;
register char lastChar;
if (strLength == 0)
return NULL;
// Initialize skip lookup table
for (i = 0; i < 256; i++)
skipTable[i] = strLength; //strlength is numbers of words in sentence
search = string; //string is array of words in the sentence
i = --strLength; // Decrease strLength here to make it an index
do {
skipTable[*search++] = i; // ---> skiptable is int array and search is string. Then what happens on LHS on each iteration???
} while (i--);
lastChar = *--search; // ---> Decreamenting string pointer? What does it mean on RHS?
do {
// Have we found the entire string?
if (i-- == 0)
return search;
} while (*--search == string[i]);
// Skip past the part of the string that we scanned already
search += (strLength - i + 1); ---> what happends here?
dataLength--;
有人可以给出--->指针的提示吗?我不知道我是否可以问这种问题,但为了我理解这些概念,我做到了!