C 语言没有布尔类型,有没有什么好办法可以实现它?
下面的方法由好及坏,
第一种,
#include <stdbool.h>
只在 C99 有效,如果可以,建议使用这个。
第二种,
typedef enum { false, true } bool;
第三种,
typedef int bool; enum { false, true };
第四种,
typedef int bool; #define true 1 #define false 0
本文分享自 作者个人站点/博客 前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!