home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!unixhub!ditka!eagercon!eagercon!eager
- From: eager@eagercon.com (Michael J. Eager)
- Subject: Re: can a pointer cast to a void* be compared to (void*)0 ?
- Message-ID: <1993Jan11.061416.2250@eagercon.com>
- Sender: root@eagercon.com (Operator)
- Reply-To: eager@eagercon.com
- Organization: Eager Consulting
- References: <C0nzI2.CqM@cs.psu.edu>
- Date: Mon, 11 Jan 1993 06:14:16 GMT
- Lines: 24
-
- In article CqM@cs.psu.edu, andrew@astro.psu.edu (Andrew Wilcox) writes:
- >This may be a FAQ, but I didn't see it in Steve Summit's excellent
- >list, so:
- >
- >Can a pointer which has been cast to a void* be directly compared with
- >a (void*)0 in ANSI C, or does the void* have to be cast back to the
- >original type before the comparision? I.e.,
- >
- > char* c = 0;
- > void* p = (void*) c;
- > if (p == 0)
- > printf( "yes\n" );
- >
- >Is this program guaranteed to print "yes"?
-
- Yes. Zero is a "special" pointer value which is guaranteed to be different
- from any valid pointer value. A zero typed pointer value will be
- converted (trivially) to a zero void pointer value.
-
- ---
- Michael J. Eager Michael.Eager@eagercon.com
- Eager Consulting (415) 325-8077
- 1960 Park Boulevard, Palo Alto, CA 94306-1141
-
-