C语言使用#define
示例
C中的所有版本,将有效地治疗以外的任何整数值0作为true比较运营商和整数值0的false。如果您没有C99_Bool或bool从C99开始可用,则可以使用#define宏在C中模拟布尔数据类型,并且您仍然可能会在旧版代码中找到这种情况。
#include <stdio.h>
#define bool int
#define true 1
#define false 0
int main(void) {
bool x = true; /* Equivalent to int x = 1; */
bool y = false; /* Equivalent to int y = 0; */
if (x) /* Functionally equivalent to if (x != 0) or if (x != false) */
{
puts("这将打印!");
}
if (!y) /* Functionally equivalent to if (y == 0) or if (y == false) */
{
puts("这也将打印!");
}
}请勿在新代码中引入此内容,因为这些宏的定义可能与的现代用法冲突<stdbool.h>。
热门推荐
10 新婚贺词祝福语创意简短
11 端午送老师祝福语简短
12 对公司年会祝福语简短
13 宝贝生日祝福语简短独特
14 男生节搞笑简短祝福语
15 祝福语闺蜜简短单纯
16 生活老师离别祝福语简短
17 生日祝福语简短大方老师
18 朝鲜元旦祝福语大全简短