C语言中没有 bool 类型

内容纲要

C语言中没有 bool 类型,但是很多地方都需要 true 和 flase,怎么解决呢?
C 语言 一般使用 10非00 表示 true 和 flase。

例如

int a = 6666;
int b = 161616;
printf("%s",a & b?"true":"flase");

a&b 的结果是一个数字,只要大于 0 或 小于 0 ,即为 true。
而且 C# 中,?: 运算符,左侧条件必须是 bool ,不能为数字。

https://www.whuanle.cn/archives/737 这里有 C语言 、 C# 利用布尔型判断的例子。

点赞
  1. bupropion说道:

    I am just writing to make you understand what a perfect experience my wife's girl obtained using your webblog. She noticed so many pieces, which included what it is like to possess an excellent helping spirit to let others with no trouble learn about specific specialized things. You truly surpassed readers' expected results. Thank you for providing these priceless, trusted, informative as well as fun tips about this topic to Lizeth.

  2. viagra pills说道:

    I needed to post you that little bit of observation to say thanks once again for your personal marvelous principles you've featured in this article. It is quite seriously generous of people like you to give openly just what many individuals might have marketed as an e book to generate some dough for themselves, most notably given that you could possibly have done it if you ever decided. These points as well served to be a fantastic way to fully grasp other people have the same passion similar to my very own to see very much more with regard to this problem. I know there are some more pleasurable situations up front for those who see your website.

发表评论

邮箱地址不会被公开。 必填项已用*标注

You must enable javascript to see captcha here!