<分区>
我想测试并查看“char”类型的变量是否可以与像“cheese”这样的常规字符串进行比较,例如:
#include <stdio.h>
int main()
{
char favoriteDairyProduct[30];
scanf("%s",favoriteDairyProduct);
if(favoriteDairyProduct == "cheese")
{
printf("You like cheese too!");
}
else
{
printf("I like cheese more.");
}
return 0;
}
(我实际上想做的比这要长得多,但这是我坚持的主要部分。) 那么如何在 C 语言中比较两个字符串呢?