Re: null and NULL: is there any difference?
Darrell Grainger wrote:[color=blue]
>
> On Wed, 24 Sep 2003, RHNewBie wrote:
>[color=green]
> > Hello,
> > What is the difference between null and NULL. Are x == null and x ==
> > NULL the same? The compiler is gcc 3.2.[/color]
>
> C language has a NULL but there is no null. When writing I use NULL to
> indicate the macro defined in <stdlib.h> and when discussing pointers.
> I use null when discussing the null character.
> By null character I am referring to '\0'.
>
> With that semantics out of the way,
> if you are asking for the difference
> between (x == '\0') and (x == NULL) it would depend on what x is.
> Off the
> top of my head, they will evaluate to the same result for all x.[/color]
if x is of type int and NULL is ((void*)0),
then the result of the comparison is not defined by the standard.
--
pete
Darrell Grainger wrote:[color=blue]
>
> On Wed, 24 Sep 2003, RHNewBie wrote:
>[color=green]
> > Hello,
> > What is the difference between null and NULL. Are x == null and x ==
> > NULL the same? The compiler is gcc 3.2.[/color]
>
> C language has a NULL but there is no null. When writing I use NULL to
> indicate the macro defined in <stdlib.h> and when discussing pointers.
> I use null when discussing the null character.
> By null character I am referring to '\0'.
>
> With that semantics out of the way,
> if you are asking for the difference
> between (x == '\0') and (x == NULL) it would depend on what x is.
> Off the
> top of my head, they will evaluate to the same result for all x.[/color]
if x is of type int and NULL is ((void*)0),
then the result of the comparison is not defined by the standard.
--
pete
Comment