I have a char array. Some of the elements allocated, and some are not.
I want to count all those not allocated without asking if (!arr[i])
char* arr[500];
.
.
.
for(i=0; i < 500; ++i)
{
if( !arr[i] )
{
counter++;
}
}
but making some bitwise magic like this in C
for(i=0; i < 500; ++i)
{
counter += !(arr[i]| 0x00); //this does not work
}
Maybe the question is more general: is there a way to compare any pointer with NULL with bitwise operations.
Edit: no, not with ==
; I understand how to do it with ==
, but I assume when it is compiled, it does not differ from if(!arr[i])
in assembler.