Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c中添加布尔值?_C - Fatal编程技术网

如何在c中添加布尔值?

如何在c中添加布尔值?,c,C,我想用类似python中的布尔值来做一个while循环 我想要像这样的东西: while(player1_health > 0 or player2_health > 0){ //code } 在C中没有或运算符,在C中我们使用符号|,称为逻辑或运算符 用这个 while( (player1_health > 0) || (player2_health > 0) ) { //code } 更新:看起来像是C99包括或,和操作员|,和&,如果您使用的是C

我想用类似python中的布尔值来做一个while循环

我想要像这样的东西:

while(player1_health > 0 or player2_health > 0){
    //code
}

C
中没有
运算符,在
C
中我们使用符号
|
,称为逻辑或运算符

用这个

while( (player1_health > 0) || (player2_health > 0) ) {
    //code
}

更新:看起来像是
C99
包括
操作员
|
和&
,如果您使用的是
C99
,它与包含头文件
#include

一起工作,也许掌握一本C编程书会是学习C编程语言的一种更快的方法,如果您使用
#include
。谢谢@JohnZwinck,我学到了一些新东西,更新了帖子,可以吗?
#include
中的“or”是一个宏,所以它不是语言的一部分。C中的“or”运算符是
|