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 恩师诗词祝福语简短大全