Null revisited (briefly)

Dave Jones djones at megatest.UUCP
Thu Mar 2 07:45:37 AEST 1989


>From article <1783 at dlvax2.datlog.co.uk>, by scm at datlog.co.uk ( Steve Mawer ):
> 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.
> 


>From _The_C_Programming_Language, Kernighan and Ritchie, (a couple
guys who probably "know the C language".)

  p. 19:  "Character constant ... is just another way to write a
          small integer."

  p. 37:  "A character constant is an integer, written as one
           character within single quotes, such as 'x'."

          "Character constants participate in numeric operations
           just as any other integers..."

> '\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.

'\0' is not a special case. It is just an instance of of the octal
escape sequences.  It is exactly the same as 0.



More information about the Comp.lang.c mailing list