A bitwise AND with ones will retrieve the bit pattern from the other operand. Meaning, . If the result of that bitwise AND is 0, then we know we know the other operand was 0. A result of 0 when ANDing a single byte with (ones) will indicate a NULL byte. The code itself checks each byte of the char array in four-byte partitions. NOTE: This code isn't portable; on another machine or compiler, an unsigned int could be more than 4 bytes.
Jonathan Leffler
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with Jonathan
Contact Jonathan, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack