Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!oresoft!dan From: dan@oresoft.uu.net (Daniel Elbaum) Newsgroups: comp.lang.c Subject: Re: Initializers for multi-dimensional arrays Message-ID: <696@oresoft.uu.net> Date: 12 Jun 89 19:53:44 GMT References: <16984@paris.ics.uci.edu> Reply-To: dan@oresoft.uu.net (Daniel Elbaum) Organization: Oregon Software, Portland, OR Lines: 39 In <16984@paris.ics.uci.edu> Doug Schmidt asks why I. static bar foo[4][4] = { {1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}, {7,0}, {8,0}, {9,0}, {10,0}, {11,0}, {12,0}, {13,0}, {14,0}, {15,0}, {16,0}, }; isn't the same as II. static bar foo[4][4] = { { {1,0}, {2,0}, {3,0}, {4,0},}, { {5,0}, {6,0}, {7,0}, {8,0},}, { {9,0}, {10,0}, {11,0}, {12,0},}, {{13,0}, {14,0}, {15,0}, {16,0},}, }; according the the latest pANSI draft and traditional UNIX C compilers. dpANSI says that the bracketing of the initialization in I requires assigning 1 to foo[0][0].i, 0 to foo[0][1].i, 2 to foo[1][0].i, 0 to foo[1][1].i, etc., since each enclosed left bracket specifies that the next nested member is to be given the following value. In other words, {2,0} says "give 2 to the first element of the next foo," which means to assign to the first element of the next array of bar. -- The workaday world must remain transparent to those who maintain it if they are to find inspired within them a vision of the history they create. ({uunet,tektronix,reed,sun!nosun,osu-cis,psu-cs}!oresoft!(dan)@oresoft.uu.net)