Path: csiph.com!aioe.org!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Nick Bowler Newsgroups: comp.lang.c Subject: Re: Treating a multi-dimensional array as one-dimensional Date: Mon, 29 Jan 2018 22:38:00 -0000 (UTC) Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <87inblexpp.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 29 Jan 2018 22:38:00 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="6c2d293543c7f6f396f95fce6b50bede"; logging-data="2033"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192sXNnyPLiDGBzhVhKd9jv" User-Agent: Pan/0.142 (He slipped to Sam a double gin; 01b5bf4 git.gnome.org/pan2) Cancel-Lock: sha1:ZsGqQeOfLRlE5+u0vvgN1f5NHzU= Xref: csiph.com comp.lang.c:125967 On Mon, 29 Jan 2018 11:00:34 +0000, Ben Bacarisse wrote: > Yes. If the array size (specifically the row length) is not known at > compile time you can do this as of C99: > > static void Print(int m, int n, int A[m][n]) > { [...] > } > > Note the parameter order and the deleted const. The new order is needed This order of parameters is not actually needed; other orders are possible by using a separate prototype. For example: static void Print(int (*)[*], int, int); static void Print(A, m, n) int m, n; int (*A)[n]; { /* ... */ }