Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!ncar!ames!elroy!jpl-devvax!timg From: timg@jpl-devvax.JPL.NASA.GOV (Tim Graham) Newsgroups: comp.lang.c Subject: Multidimensional Static Array Initialization Follow-up Message-ID: <2682@jpl-devvax.JPL.NASA.GOV> Date: 18 Aug 88 00:29:45 GMT Reply-To: timg@jpl-devvax.JPL.NASA.GOV (Tim Graham) Organization: Jet Propulsion Laboratory, Pasadena, CA. Lines: 51 Hello again everyone, From a couple of the responses which I have received (thanks, by the way, to those who took the trouble to respond), it has become fairly clear that I didn't express myself completely clearly in my original posting. I am not under the impression that C multi-dimensional arrays are non-rectangular; it is precisely because of their rectangularity that it appears so easy to implement initialization in a manner analogous to 1-D static array (without size declarator) initialization. For example, if we have the declaration int foo[][4] = { { 1, 2, 3, 4 }, { 5, 8 }, { 9, 10, 12 } }; then the unitialized elements in the 3x4 array are filled with zeros. Is it really that much harder for it to be possible to implement a declaration like int foo[][] = { { 1, 2, 3, 4 }, { 5, 8 }, { 9, 10, 12 } }; and have it do exactly the same thing without the bother of me having to know in advance what the largest number of elements to appear in any row is going to be? It seems as though it would be possible for a compiler to calculate how large each of the dimensions would need to be and then just allocate the space. There's not even any memory wasted since, whether I have to declare in advance how large each dimension is or not, the resultant array is the same size. So, what I meant to ask in my original posting was why are things not implemented in this way? Thanks again to those who responded to my query, and thanks in advance to those who will respond. Tim Graham ================================================================================ "Freedom without order and order without freedom are equally destructive" - Teddy Roosevelt Jet Propulsion Laboratory/California Institute of Technology 4800 Oak Grove Drive Pasadena, CA. 91109 MS: 301-260A (818) 354-1448 UUCP: ...cit-vax!elroy!jpl-devvax!timg ARPA: elroy!timg@jpl-devvax ================================================================================