Finding NULL byte in a long

Walter Bright bright at nazgul.UUCP
Tue Dec 11 08:05:25 AEST 1990


In article <1990Dec5.033206.10463 at nimbus3.uucp> djs at nimbus3.UUCP (Doug) writes:
/I know this has been on the net before, since I thought I saved it,
/but can't find it now.  Anyway, could someone tell me what the
/C expression is that tells you if a long has a NULL byte in it.
/This is without masking each byte and testing it for 0.  It is very
/clever and non-obvious.  Thanks.

Hmmm, how about:
	p = memchr(&x,0,sizeof(x));



More information about the Comp.lang.c mailing list