Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Null revisited (briefly) Message-ID: <2557@goofy.megatest.UUCP> Date: 1 Mar 89 21:45:37 GMT References: <1783@dlvax2.datlog.co.uk> Organization: Megatest Corporation, San Jose, Ca Lines: 29 From article <1783@dlvax2.datlog.co.uk>, by scm@datlog.co.uk ( Steve Mawer ): > In article <10138@socslgw.csl.sony.JUNET> diamond@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.