array of arrys

Discussion in 'C Programming' started by Bill Cunningham, Dec 2, 2007.

  1. 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
    Bill Cunningham, Dec 2, 2007
    #1
    1. Advertising

  2. "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) <>
    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"
    Keith Thompson, Dec 2, 2007
    #2
    1. Advertising

  3. Bill Cunningham

    santosh Guest

    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>
    santosh, Dec 2, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel
    Replies:
    1
    Views:
    1,048
    Kevin Collins
    Aug 14, 2003
  2. S300
    Replies:
    4
    Views:
    21,988
    Roedy Green
    Aug 19, 2003
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    486
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    207
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    470
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page