Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!milano!lad-shrike!ut-emx!reeder From: reeder@ut-emx.UUCP (William P. Reeder) Newsgroups: comp.lang.c Subject: initializing an array Keywords: multi-dimension, no size specified. Message-ID: <12814@ut-emx.UUCP> Date: 5 May 89 16:28:47 GMT Organization: University of Texas Computation Center Lines: 38 I can initialize a simple array like this: int a[] = { 1, 2, 3 }; and C will figure out that a must have 3 elements. But what if my array has two dimensions? int a[][] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, }; It is possible to determine from the syntax how many elements there are in each dimension, but my compiler complains about a null dimension. Section 8.6 of K&R (1st edition) says: When the declared variable is an aggregate (a structure or array) then the initializer consists of a brace-enclosed, comma-separated list of initializers for the members of the aggregate, written in increasing subscript or member order. If the aggregate contains subaggregates, this rule applies recursively to the members of the aggregate. The last sentence claims that the initialization process is recursive. Well, if determining the size of an (one dimensional) array can be done during initialization, why not for the sub-array (a 2-d array is really just an array of arrays, right?) ? Any thoughts? Please reply via e-mail to reeder@emx.utexas.edu (or uunet!cs.utexas.edu!ut-emx!reeder) since I don't normally read this group. William Reeder, University of Texas at Austin, Computation Center reeder@emx.utexas.edu -- DISCLAIMER: I speak only for myself, and usually only to myself.