VS2019中有未经处理的异常: 0xC0000005: 读取位置 时发生访问冲突。
int numMatchingSubseq(char* s, char** words, int wordsSize)
{
int ret = 0;
int len = strlen(s);//计算s的长度
for (int i = 0; i < wordsSize; i++)//遍历words的字符串
{
int n = 0;
for (int j = 0; j < len; j++)//在s中按次序查找words的字符
{
if (s[j] == words[i][n])//当字符相同时计数器+1
{
n++;
if (words[i][n] == '\0')//当words[i]字符串查找到最后时就在返回值上加一
{
ret++;
break;
}
}
}
}
return ret;
}
int main()
{
char s[] = "abcde";
char words[][50] = { "a","bb","acd","ace" };
int ret = numMatchingSubseq(&s, words[0], 4);
printf("%d", ret);
return 0;
}