如何在C中比较不区分大小写的两个字符?

Ant*_*PRİ 2 c arrays string compare char

我正在尝试比较两个字符串中的两个特定字符,但是我想进行不区分大小写的比较。我怎样才能做到这一点?

现在我正在使用这样的代码:

if (str1[i]==str2[j]) printf("Equal");
Run Code Online (Sandbox Code Playgroud)

但我想这样做时不区分大小写。

预先感谢您抽出宝贵时间为您提供帮助!

Ale*_*lex 5

您可以对两个字符使用小写字母,例如,使用tolower函数:

if (tolower(str1[i])==tolower(str2[j])) printf("Equal");
Run Code Online (Sandbox Code Playgroud)

另外请记住:tolower不适用于多字节char。因此,对于那些字符,您应该使用其他功能