Hi All,

I want to detect if any NULL bytes exist in a char array.

Consider the following code snippet:

Code:
char buffer[1000000];
ifstream fstr("myfile", ios::binary);
fstr.read(buffer, 1000000);
//check if buffer has any NULL characters
for(int i = 0; i < 1000000; i++)
{
     if(!buffer[i]) detected = true;
}
Assuming that fstr has 1000000 bytes, constructing a for loop like above seems inefficient (in terms of speed) to me to detect NULL characters.

Buffer length could be much higher.

Which methodology do you suggest to detect NULL characters in the fastest way in a char array ?

Thanks.