请帮助我理解我的双指针算法做错了什么。我知道我显然做错了什么,但是什么?看看我标记的行,“坏指针”。我的直觉告诉我这应该可行,但我想不是。用 C 编程。
/*
*This function searches for prefixes within the string array.
*@param stringArray array containing strings
*@param searchPrefix a string or characters to search for at beginning of string
*@return void
*/
void prefixSearch(char* stringArray[SIZE], char* searchPrefix){
int count = strlength(searchPrefix);//size of the prefix search
while(count > 0){
if(**stringArray == *searchPrefix){
printf("%c match %c\n", **stringArray, *searchPrefix);
**stringArray++;//want to move to next character, instead get bad pointer.
*searchPrefix++;//moves to next char
}else{
stringArray++;//no match, go to next string
}
count--;//decrement
}
}