如何检查 bool 数组中的所有值是否为真?

How to check if all values in bool array are true?

C, 检查 bool table 中的所有值是否为真的最好和最简单的方法是什么? 我尝试过类似的方法,但它不起作用

for(i = 0; i < value; i++){
            if(bool_table[i] == 0)
                table_true = 0;
            else
                table_true = 1;
    }

这段代码的问题在于,有时如果第一个值为真,那么它会设置 table_true = 1

像这样应该可以解决问题:

table_true = 1;
for(i = 0; i < value; i++)
        if (!bool_table[i]) {
            table_true = 0;
            break;
        }

如果以下循环遍历整个数组而没有找到 false 条目,则在循环结束时 i 将等于 value

for(i = 0; i < value; i++)
    if ( !bool_table[i] )
        break;

table_true = (i == value);

我不确定如何评价 "best" 或 "simplest." "best" 是否意味着最快?或者最少的代码行?最简单的,对初学者来说是最简单的吗?还是一群吃C睡C,经常用指针的开发者?

这是我的一些非常规方法:

bool *each = bool_table; // pointer to first element
bool *end = each + value; // stop condition
while (*each && each != end) {
    each++;
}
return each != end;