home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19881 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.2 KB  |  34 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!stanford.edu!EE.Stanford.EDU!sierra!mcgrant
  3. From: mcgrant@rascals.stanford.edu (Michael C. Grant)
  4. Subject: Re: Is (p) instead of (p!=NULL) portable? 
  5. In-Reply-To: robert@alkymi.unit.no's message of Mon, 25 Jan 93 12:56:27 GMT
  6. Message-ID: <MCGRANT.93Jan25110332@rascals.stanford.edu>
  7. Sender: usenet@EE.Stanford.EDU (Usenet)
  8. Organization: Information Systems Laboratory, Stanford University
  9. References: <1993Jan25.125627.29030@ugle.unit.no>
  10. Date: 25 Jan 93 11:03:32
  11. Lines: 21
  12.  
  13. In article <1993Jan25.125627.29030@ugle.unit.no>
  14. robert@alkymi.unit.no (Robert Schmidt) writes:
  15.  
  16.    In PC C's, the NULL pointer is defined with a bit pattern of all zero's,
  17.    and the constructs 
  18.          if (p)
  19.    and
  20.          if (!p)
  21.    checks for NULL and non-NULL respectively.  Is this portable to *all*
  22.    platforms?
  23.  
  24. Yes. By definition, 'if (p)', if p is a pointer, tests to see if p is equal
  25. to the null pointer, and 'if (!p)' tests to see if it is not.
  26.  
  27. Also, by definition, 'p = 0' sets p to the null pointer, even if the
  28. internal representation of the null pointer is not all zeros for some reason.
  29.  
  30. Mike
  31.  
  32. --
  33. "Long hair, short hair--what's the difference once the head's blowed off?" (?)
  34.