Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: prototyping (oh no! not again??) Message-ID: <1990Nov27.163716.23883@zoo.toronto.edu> Organization: U of Toronto Zoology References: Date: Tue, 27 Nov 90 16:37:16 GMT In article davis@pacific.mps.ohio-state.edu (John E. Davis) writes: > I have a function that takes a 2-d array of unknown dimension and does > things with it. How do I declare and call it? You can't do this in C. Period. Indexing into the array requires knowing the size of the rows in the array. C insists on knowing this at compile time, so the second dimension must be declared as a specific number. The only way out of this is to pass a pointer to the array as if it were one-dimensional, and do the indexing arithmetic yourself. > I tried this: > double trace(double **matrix, int dim) Sigh. Please see any good C textbook for the differences between pointers and arrays. This is wrong no matter what shape your array has. -- "I'm not sure it's possible | Henry Spencer at U of Toronto Zoology to explain how X works." | henry@zoo.toronto.edu utzoo!henry