Velocity Reviews > array of arrys

# array of arrys

Bill Cunningham
Guest
Posts: n/a

 12-02-2007
Many thanks to Santosh with that link to a simpler descibed k&r2. I'm
learning slowly.

But here's the question:

int [3][7];

A two dimensional array says three something are arrays of type int each
containing arrays of 7 elements. What about the first dimension [3]? Is it
type int too?

Bill

Keith Thompson
Guest
Posts: n/a

 12-02-2007
"Bill Cunningham" <(E-Mail Removed)> writes:
> Many thanks to Santosh with that link to a simpler descibed k&r2. I'm
> learning slowly.
>
> But here's the question:
>
> int [3][7];
>
> A two dimensional array says three something are arrays of type int each
> containing arrays of 7 elements. What about the first dimension [3]? Is it
> type int too?

In C, a two dimensional array is exactly the same thing as an array of
arrays. If you understand C arrays (which is no small feat in
itself), then everything about multidimensional arrays follows from
that.

The above declaration doesn't actually declare anything. I think what
you meant was:

int array_object[3][7];

array_object itself is of type "array 3 of array 7 of int". It's an
array consisting of 3 elements; each element is of type "array 7 of
int". Each element of each element of array_object is of type int.

(The indices can be of any integer type. The index type isn't part of
an array type; only the length of each dimension is.)

If you haven't already done so, take a look at the comp.lang.c FAQ,
<http://www.c-faq.com/>, particularly section 6.

--
Keith Thompson (The_Other_Keith) <(E-Mail Removed)>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

santosh
Guest
Posts: n/a

 12-02-2007
Bill Cunningham wrote:

> Many thanks to Santosh with that link to a simpler descibed k&r2.
> I'm
> learning slowly.
>
> But here's the question:
>
> int [3][7];
>
> A two dimensional array says three something are arrays of type int
> each containing arrays of 7 elements. What about the first dimension
> [3]? Is it type int too?

playing around with a nifty little program called 'cdecl'. It knows a
lot about C syntax and can translate a C declaration to an English
description or vice versa. It should be in pure ISO C and hence should
compile with minimal fuss on all systems with a conforming compiler.

Get a package from:

<http://linux.maruhn.com/sec/cdecl.html>

And here is the manpage:

<http://linuxcommand.org/man_pages/cdecl1.html>

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mara Guida C Programming 3 09-03-2009 07:54 AM Tuan Bui Perl Misc 14 07-29-2005 02:39 PM Tom Perl Misc 3 12-20-2004 05:23 PM S300 Java 4 08-19-2003 07:04 PM Daniel Perl 1 08-14-2003 06:49 PM