Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!midway!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: sizeof and multi-dimensional arrays Message-ID: <29035@mimsy.umd.edu> Date: 9 Jan 91 06:16:10 GMT References: <1991Jan5.050613.22303@Neon.Stanford.EDU> <1991Jan8.234328.5075@sol.UVic.CA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 34 In article <1991Jan8.234328.5075@sol.UVic.CA> gmclaren@sirius.UVic.CA (Gavin Mclaren) writes: >>char x[2][3]; >What's to be confused about? x is a pointer to a two dimensional array, No, x is an . There is one thing to be confused about already. (To get a pointer to x, write `&x'. This gives a .) >Is this perhaps an example of how some are confused by the pointer-array >equivalence _theory_ in the C language? Yes. There is no real `pointer-array equivalence'; there is, however, a (one, single) rule that makes the use of arrays and pointers use the same syntax. That rule is: In a value context, an object of type `array N of T' (where N is some integral constant and T is a suitable type, including another `array Nprime of Tprime') is converted to a value of type `pointer to T' which points to the first element of the array, i.e., the one with subscript 0. This conversion occurs only in value contexts. (There is a completely separate rule that applies to formal parameter declarations.) >My best advice is to muddle through the FAQ, one more time.... The FAQ answers are not intended as full tutorials (there is not enough space, among other things). For much more detail about this, see my previous postings. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris