Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
puts("Type your name"); gets(name); if(name=="exit"){ exit(0); }
如果我的逻辑条件错误,我该如何修复它?
既然name是字符串,为什么不使用strcmp函数?
name
strcmp
if (strcmp(name, "exit") == 0) { exit(0); }
您不能以这种方式比较字符串,请使用strcmp,或者最好使用strncmp