puts("Type your name");
gets(name);
if(name=="exit"){
exit(0);
}
if 中的逻辑条件错误,如何修复?
最佳答案
既然name
是一个字符串,为什么不使用strcmp
函数呢?
if (strcmp(name, "exit") == 0)
{
exit(0);
}
关于c - C 语言中 if 与字符串的逻辑条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16885655/