Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mimsy!eneevax!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.UUCP Newsgroups: comp.lang.c Subject: Re: Trouble with arrays Message-ID: <5898@brl-smoke.ARPA> Date: Thu, 28-May-87 00:32:08 EDT Article-I.D.: brl-smok.5898 Posted: Thu May 28 00:32:08 1987 Date-Received: Sat, 30-May-87 11:30:49 EDT References: <40@gt-eedsp.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Distribution: na Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 45 In article <40@gt-eedsp.UUCP> deb@gt-eedsp.UUCP (Deb Jackson) writes: > static float X[MAXOUTSIZE][MAXOUTSIZE]; /* input image */ > writearray(X, (dim + L - 1)); > writearray(a, size) > float a[MAXOUTSIZE][MAXOUTSIZE]; >(dbx) whatis writearray.a > array[0..62] of float *a; >(dbx) whatis writearray.writearray.a > array[0..MAXINT] of float *a; >Is this dbx that is messing up, or am I missing the point entirely? Both. "Dbx" is hopelessly confused... What you need to realize is that your invocation of writearray() has as its first actual parameter the NAME of the array. In C, the name of the array (in most contexts) is converted to a pointer to the first element of the array (which in this case contains 1-dimensional arrays as elements). You have not passed the data bits themselves to the function, but rather a pointer that can be used to locate them. Because of this characteristic, the formal parameter in the function, which (unfortunately) Dennis decided to allow one to write as though it were the actual array declaration, is converted to a pointer to the first element so that it might as well be written: writearray(a, size) float (*a)[MAXOUTSIZE]; /* this is the SECOND dimension */ or, alas, the special-case syntax: writearray(a, size) float a[][MAXOUTSIZE]; There is no way (short of embedding the array in a structure) to pass the data bits themselves directly into the function as a parameter; there isn't even a syntax for that, given the C meaning of the name of an array. If I were designing C (assuming I could, which isn't realistic), I would require the first of the two equivalent forms I just gave as the only correct formal parameter declaration (modulo extra grouping parentheses), instead of supporting the "convenient" syntactic sugar that permits your original example. However, we're now stuck with the decision, so I recommend that you code the form I suggest, to make patently clear exactly what the type and meaning of the parameter really is. That will reduce confusion.