Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: How to pass arbitrary 2-d array argument ?
Message-ID: <1991Jan6.052238.16398@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1991Jan6.044056.23028@noose.ecn.purdue.edu>
Date: Sun, 6 Jan 91 05:22:38 GMT

In article <1991Jan6.044056.23028@noose.ecn.purdue.edu> luj@delta.ecn.purdue.edu (Jun Lu) writes:
>It would be nice if I can have a "subroutine" which takes arbitrary matrices as
>arguments and performs some operations on them. The dimensions of the 2-d
>array are not known a priori...

Can't be done in C.  The dimensions of an array, with the exception of the
first, must be known at compile time.

(Well, "can't be done" is an exaggeration, but what you end up doing is
cheating, declaring the arguments as pointers and doing the subscript
arithmetic yourself rather than using [] notation.)

This is generally considered a deficiency, but it is harder to solve than
it looks.  Some compilers have extensions to do it, although most of those
extensions have problems of one kind or another.  There is work being done
on finding a good solution.
-- 
If the Space Shuttle was the answer,   | Henry Spencer at U of Toronto Zoology
what was the question?                 |  henry@zoo.toronto.edu   utzoo!henry
