Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #125970

Re: Treating a multi-dimensional array as one-dimensional

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Treating a multi-dimensional array as one-dimensional
Date 2018-01-29 23:07 +0000
Organization A noiseless patient Spider
Message-ID <87607ke02x.fsf@bsb.me.uk> (permalink)
References <p4mq61$1k5n$1@gioia.aioe.org> <87inblexpp.fsf@bsb.me.uk> <p4o7o7$1vh$1@dont-email.me>

Show all headers | View raw


Nick Bowler <nbowler@draconx.ca> writes:

> 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];
>   {
>     /* ... */
>   }

Blimey!  A use for a pre-ANSI C function definition.  That would not
have occurred to me (obviously).  Thanks.  In a weird way that's made my
day.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Treating a multi-dimensional array as one-dimensional August Karlstrom <fusionfile@gmail.com> - 2018-01-29 10:40 +0100
  Re: Treating a multi-dimensional array as one-dimensional Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-01-29 11:00 +0000
    Re: Treating a multi-dimensional array as one-dimensional supercat@casperkitty.com - 2018-01-29 07:58 -0800
    Re: Treating a multi-dimensional array as one-dimensional Nick Bowler <nbowler@draconx.ca> - 2018-01-29 22:38 +0000
      Re: Treating a multi-dimensional array as one-dimensional Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-01-29 23:07 +0000
  Re: Treating a multi-dimensional array as one-dimensional Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-01-29 03:29 -0800
    Re: Treating a multi-dimensional array as one-dimensional August Karlstrom <fusionfile@gmail.com> - 2018-01-29 21:35 +0100

csiph-web