Path: utzoo!attcan!uunet!lll-winken!csd4.milw.wisc.edu!mailrus!ames!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Null revisited (briefly) Keywords: NULL Message-ID: <16158@mimsy.UUCP> Date: 1 Mar 89 11:58:01 GMT References: <13068@steinmetz.ge.com> <102@servio.UUCP> <1783@dlvax2.datlog.co.uk> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 >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. This is correct. In article <1783@dlvax2.datlog.co.uk> scm@datlog.co.uk ( Steve Mawer ) writes: >Not if he knows the C language. A single character written within >single quotes is a *character constant*. This isn't an int. False. A character constant is an int (not a char) whose value is the representation of that character in the machine's character set (typically ASCII; EBCDIC is confused about where the []s go, and sometimes does not have {} \ and ~, depending on which EBCDIC you are using---there are at least three major variants). >'\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. Aside from the backslash interpretation, '\0' is *not* a special case. The type of '\0' is int and its value is zero, no matter what the character set; this is guaranteed by the C language. (The pair for an unadorned 0 is also , although the pair of something like 65432 is sometimes .) >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. This is correct. It is hard to predict whether (char)'abcd' will be the same as (char)'a' or (char)'d' (or even b or c), so it is best to avoid these. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris