Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!ruuinf!prisma!fred From: fred@prisma.cv.ruu.nl (Fred Appelman) Newsgroups: comp.lang.c Subject: Re: sizeof and multi-dimensional arrays Message-ID: Date: 5 Jan 91 09:51:00 GMT References: <1991Jan5.050613.22303@Neon.Stanford.EDU> Organization: University of Utrecht, 3D Computer Vision, The Netherlands Lines: 23 In <1991Jan5.050613.22303@Neon.Stanford.EDU> dkeisen@Gang-of-Four.Stanford.EDU (Dave Eisen) writes: >Is the following a compiler bug or am I just confused? > >char x[2][3]; > > sizeof (*x) gives 6 > sizeof (x[0]) gives 3. > >What's the scoop? > You are just confused. 'x' is a two dimensional array of 2*3 elments of type char. Makes a total of 6. 'x[0]' and 'x[1]' are arrays with a length of 3 elements. So both arrays have a size of 3. Fred -- Fred J.R. Appelman, 3D Computer Vision, Utrecht University AZU, Heidelberglaan 100, 3584 CX Utrecht, The Netherlands. Telephone: +31-30-506710 Fax: +31-30-513399 e-mail: fred@cv.ruu.nl or appelman@cs.unc.edu