Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!munnari.oz.au!comp.vuw.ac.nz!actrix!templar!jbickers From: jbickers@templar.actrix.co.nz (John Bickers) Newsgroups: comp.lang.c Subject: Re: Initializing arrays of char Message-ID: <6568.tnews@templar.actrix.co.nz> Date: 5 Oct 90 18:55:00 GMT Followup-To: comp.lang.c Organization: TAP, NZAmigaUG. Lines: 22 Quoted from - poser@csli.Stanford.EDU (Bill Poser): > ...the number of characters in the string, NOT COUNTING > THE TERMINATING NULL CHARACTER, must not exceed the > size of the array. [emphasis mine] > an error. Not counting the terminating null here is inconsistent. > Can anyone explain this decision? Sounds like this is intended to allow a nice way to initialize character arrays that aren't necessarily strings. Like, say, a 4 character ID in a structure, that is meant to be compared and writ with things like mem... or strn... Consider that a character array is not necessarily going to be used as a "string", and since C doesn't distinguish between the two with any sort of type keyword, it's better to provide for the more general case. Does lint warn about this sort of thing? -- *** John Bickers, TAP, NZAmigaUG. jbickers@templar.actrix.co.nz *** *** "All I can do now is wait for the noise." - Numan ***