Passing Multidimensional Arrays

Joseph S. D. Yao jsdy at hadron.UUCP
Thu Dec 19 17:06:08 AEST 1985


(First off, the original code fragment, while syntactically legal C,
was most definitely semantically incorrect.)

In article <397 at codas.UUCP> mikel at codas.UUCP (Mikel Manitius) writes:
>                             ... Then explain, if you don't mind, how
>the compiler knows the dimensions of argv in the following construct:
>#include <stdio.h>
>main(argc, argv)
>int	argc;
>char	*argv[];
>{
>	int	i, j;
>	for(j=0;argv[j][0] != '\0';j++) {
>		for(i=0;argv[j][i] != '\0';i++)
>			putc(argv[j][i], stdout);
>		putc('\n', stdout);
>		}
>}

Easy.  Argv is  n o t  a 2-D array.  It is an array of pointers.
If my yesterday's article on the subject hasn't arrived at your
machine yet, wait a couple days and then  m a i l  to me to see
whether I can retrieve a copy for you.

If anyone kept a copy of my 100+ line diatribe on arrays and
pointers, and why people confuse them so, from a year ago, wouldst
please mail a copy to me?  I'm afraid I didn't keep a copy, and
if this line of discussion keeps up, I'm going to need it.	;-}
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.lang.c mailing list