-1
我有两个结构数组和一个嵌套for循环。这两个数组中有相同的单词,但strcasestr未检测到它们。我使用strcasestr在相同的单词中查找子字符串。strcasestr无法正常工作
这里是我的代码片段:
for(int itr = 0; itr < arrayItr; itr++)
{
for(int itr2 = 0; itr2 < arrayItr2; itr2++)
{
if(strcasestr(termsArraypast[itr].term, termsArrayTerms[itr2].term) > 0)
{
printf("%d %d %s\n", termsArraypast[itr].charDistance, termsArraypast[itr].termDistance, termsArraypast[itr].term);
}
}
}
请知道,所有这些变量已经在我的程序申报。我刚刚在这个部分工作了好几个小时,但无法弄清楚。谢谢。
的条件是错误的。 'strcasestr'函数返回一个指向子串开始的指针,如果没有找到该串,则返回NULL。整个技术上非空值大于零,你仍然应该比较'NULL'。 –
至于问题,你传递给函数的两个字符串的内容是什么? –