大家好,又见面了,我是你们的朋友全栈君。
C语言中没有BOOL类型变量,它是C++独有的,由于使用BOOL类型可以使代码更具有可读性,很多编程者都在C中自己定义了类似的应用,一般方法有两种:
第一种:采用宏定义方式
typedef int BOOL;
#define true 1
#define false 0
或写为:
#ifndef bool
#define bool int
#endif
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
第二种:采用枚举型变量方式
typedef enum{false=0,true}BOOL;
转载于:https://www.cnblogs.com/zhangwuji/p/5332369.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/138869.html原文链接:https://javaforall.net