_Bool和布尔类型C的区别? [英] Difference between _Bool and bool types in C?

查看:113
本文介绍了_Bool和布尔类型C的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我解释一下什么是用C _Bool和布尔数据类型之间的区别吗?
例如:

  _Bool X = 1;
  布尔Y =真实的;  的printf(%D,X);
  的printf(%D,Y);


解决方案

在C99中添加这些数据类型。由于布尔不是之前C99保留,他们使用 _Bool 关键字(这是保留的)。

布尔 _Bool 如果您有一个别名 stdbool.h 。基本上,包括 stdbool.h 头是一个迹象,你的code是与标识符确定布尔是保留,即你的code将不会使用它来达到自己的目的(类似的标识符真正)。

Can anyone explain me what is a difference between _Bool and bool data type in C ? For example

 _Bool x = 1;
  bool y = true;

  printf("%d", x);
  printf("%d", y);

解决方案

These data types were added in C99. Since bool wasn't reserved prior to C99, they use the _Bool keyword (which was reserved).

bool is an alias for _Bool if you include stdbool.h. Basically, including the stdbool.h header is an indication that your code is OK with the identifier bool being 'reserved', i.e. that your code won't use it for its own purposes (similarly for the identifiers true and false).

这篇关于_Bool和布尔类型C的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆