use of if (!cptr) and if (cptr), where cptr is a *)
    Walter Murray 
    walter at hpclwjm.HP.COM
       
    Thu Jul 27 02:44:37 AEST 1989
    
    
  
Jeff Leyser writes:
> OK, this may be meaningless, but out of curiosity is:
> 	if (cptr == (int) 0)
> illegal C, or simply compleat garbage?
It's perfectly legal, if a little misleading.  As a further
examle of the latitude you have in writing a null pointer
constant, the following would also be legal.
   if (cptr == (signed short)0.3+sizeof(char)-'\1'
	       +sizeof((long int*)myfunc()+3,000)-sizeof'M');
I think any ANSI-conforming compiler will accept this statement.
Walter Murray
Not speaking for Hewlett-Packard or X3J11
    
    
More information about the Comp.lang.c
mailing list