Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > array of arrys

Reply
Thread Tools

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


 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      12-02-2007
"Bill Cunningham" <> 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) <kst->
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"
 
Reply With Quote
 
 
 
 
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?


In addition to Keith excellent answer I also recommend downloading and
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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
How to combine 2 int Array into ONE int Array ? S300 Java 4 08-19-2003 07:04 PM
hashed array in array need the keys... and length Daniel Perl 1 08-14-2003 06:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57