How to check whether all bytes in a memory block are zero

后端 未结 10 708
渐次进展
渐次进展 2021-02-03 21:05

I have a block of memory with elements of fixed size, say 100 bytes, put into it one after another, all with the same fixed length, so memory looks like this

&l         


        
10条回答
  •  别跟我提以往
    2021-02-03 21:35

    What about using long int and binary or operator.

    unsigned long long int *start, *current, *end, value = 0;
    // set start,end
    for(current = start; current!=end; current++) {
    value |= *current;
    }
    bool AllZeros = !value;
    

提交回复
热议问题