Path: utzoo!attcan!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: Initializing arrays of char Message-ID: <21242:Oct604:56:1390@kramden.acf.nyu.edu> Date: 6 Oct 90 04:56:13 GMT References: <14796@mentor.cc.purdue.edu> <9418:Oct503:06:2790@kramden.acf.nyu.edu> <3568@dftsrv.gsfc.nasa.gov> Organization: IR Lines: 16 In article <3568@dftsrv.gsfc.nasa.gov> jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) writes: > You forget that doing "char baz[] = "12345";" is the same as: > char baz[] = { '1','2','3','4','5','\0' }; That's what I said. Null-terminated character arrays are called strings, and my point was that the original poster was *not* asking about them. Again, the right way to initialize a five-element character array is to list the five characters explicitly: char baz[5] = { '1', '2', '3', '4', '5' } ; If you use "12345", you'll confuse the reader (not to mention any old compilers) into thinking that you really want a (0-terminated) string. ---Dan