gpt4 book ai didi

c - while 字符串出错

转载 作者:行者123 更新时间:2023-11-30 18:17:04 24 4
gpt4 key购买 nike

char str[6];

do
{
printf("Enter the string you wanna check:");
scanf("%s", str);

}
while(str != "exit");

为什么这不起作用?

最佳答案

str永远不会等于“exit”,因为您正在比较两个不同内存部分的地址。您可能想要比较字符串的内容,为此有一个函数strcmp()

关于c - while 字符串出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45468725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com