Can I check in C(++) if an array is all 0 (or false)?

后端 未结 8 593
执念已碎
执念已碎 2020-12-21 01:34

Can I check in C(++) if an array is all 0 (or false) without iterating/looping over every single value and without allocating a new array of the same size (to use memc

8条回答
  •  情歌与酒
    2020-12-21 01:38

    No, you can compare arrays with memcmp, but you can't compare one value against a block of memory.

    What you can do is use algorithms in C++ but that still involves a loop internally.

提交回复
热议问题