【发布时间】:2020-09-26 05:50:29
【问题描述】:
以下哪种返回类型是以下相等性检查的正确类型?为什么?
int foo1(short x) {
return x<0;
}
short foo2(short x) {
return x<0;
}
char foo3(short x) {
return x<0;
}
#include <stdbool.h>
bool foo4(short x) {
return x<0;
}
【问题讨论】:
-
拥抱 C99 并前往
bool。 -
x<0是关系测试,而不是相等测试。