Skip site navigation (1)Skip section navigation (2)
Date:      18 Feb 1997 06:28:01 -0600
From:      Zach Heilig <zach@blizzard.gaffaneys.com>
To:        John-Mark Gurney <gurney_j@resnet.uoregon.edu>
Cc:        Peter Mutsaers <plm@xs4all.nl>, freebsd-bugs@freefall.freebsd.org
Subject:   Re: bin/2752: NULL is used instead of 0 many places
Message-ID:  <87bu9ib8oe.fsf@murkwood.gaffaneys.com>
In-Reply-To: John-Mark Gurney's message of Tue, 18 Feb 1997 00:14:59 -0800 (PST)
References:  <Pine.BSF.3.95q.970218001257.18336B-100000@hydrogen.nike.efn.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John-Mark Gurney <jmg@nike.efn.org> writes:

> yes... but he's talking about this:

> char a = '\0';

> this way the compiler KNOWS it's a char... and that it's the nul
> char...  and doesn't convert the int 0 to char 0...

But, it doesn't know that '\0' is a 'char', since it really is an
'int'.  The only real reason to use '\0' instead of a plain 0 is
stylistic only.  ANSI C does not have character constants, though C++
does.  Check out this small program:

#include <stdio.h>
int
main(void)
{
    printf("sizeof (char) is: %d\n", (int) sizeof (char));
    printf("sizeof '\\0'   is: %d\n", (int) sizeof '\0');
    printf("sizeof (int)  is: %d\n", (int) sizeof (int));

    return 0;
}


-- 
Zach Heilig (zach@blizzard.gaffaneys.com) | ALL unsolicited commercial email
Support bacteria -- it's the only         | is unwelcome.  I avoid dealing
form of culture some people have!         | with companies that email ads.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87bu9ib8oe.fsf>