【发布时间】:2018-01-10 03:28:25
【问题描述】:
char str[6];
do
{
printf("Enter the string you wanna check:");
scanf("%s", str);
}
while(str != "exit");
为什么这不起作用?
【问题讨论】:
-
定义“不工作”
-
当用户进入“退出”时,循环不会中断。
-
你不是在比较字符串,而是指向
char的指针。如前所述,使用strcmp()。 -
欢迎来到 StackOverflow!检查this out。
标签: c