Path: utzoo!utgpu!attcan!uunet!kddlab!icot32!nttlab!gama!etlcom!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: Null revisited (briefly) Keywords: NULL Message-ID: <10138@socslgw.csl.sony.JUNET> Date: 20 Feb 89 03:57:55 GMT References: <13068@steinmetz.ge.com> <102@servio.UUCP> Sender: news@csl.sony.JUNET Reply-To: diamond@diamond. (Norman Diamond) Organization: /usr/lib/news/organization Lines: 25 In article <102@servio.UUCP> penneyj@servio.UUCP (D. Jason Penney) writes: [for null-terminating a C string] >char aString[20]; >aString[0] = '\0'; Yes, this is fine. >'x' is a literal of type char. Thus, '\0' is the char with value 0, >which is really what was intended here. In fact, 'x' is a literal of type int, and '\0' is the same as 0. >When you assign an int or a pointer to a character, the reader ends >up wondering if the type mismatch is unintentional. When you assign 'x' to a character, you are assigning an int to a character. The reader knows that the type mismatch was intentional. But readers who do not understand the type mismatch often make different errors, where results are counter-intuitive. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-inventing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?