Null revisited (briefly)

Steve Mawer scm at datlog.co.uk
Mon Feb 27 18:50:49 AEST 1989


In article <10138 at socslgw.csl.sony.JUNET> diamond at diamond. (Norman Diamond) writes:
>
>When you assign 'x' to a character, you are assigning an int to a
>character.  The reader knows that the type mismatch was intentional.

Not if he knows the C language.  A single character written within
single quotes is a *character constant*.  This isn't an int.

'\0' is a special case to permit the representation of non-graphical
characters (also newline, tab, backslash, return, etc.) and is not
the same as 0, which is an integer constant.

It should, however, be noted that some compilers will allow the use
of multiple characters, as in 'abcd' (which *may* work on 32 bit
machines).  I wouldn't recommend this usage in portable software.
(In fact I wouldn't *ever* do it.  Well, maybe just to try it :-))
-- 
Steve C. Mawer        <scm at datlog.co.uk> or < {backbone}!ukc!datlog!scm >
                       Voice:  +44 1 863 0383 (x2153)



More information about the Comp.lang.c mailing list