Re: Are 2D arrays contiguous?

Discussion in 'C Programming' started by daniel, Aug 15, 2008.

  1. daniel

    daniel Guest

    On Aug 15, 1:38 pm, Tristan Miller <>
    wrote:
    > Greetings.
    >
    > Are statically allocated two-dimensional arrays guaranteed to be
    > contiguous, or is it possible the compiler will allocate padding after
    > each row?  Is the following code OK?
    >
    > #include <string.h>
    >
    > int main(void) {
    >   char a[5][5];
    >   memset(a, 'x', 25);
    >   return 0;
    >
    > }
    >
    > Regards,
    > Tristan
    >
    > --
    >    _
    >   _V.-o  Tristan Miller [en,(fr,de,ia)]  ><  Space is limited
    >  / |`-'  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  <>  In a haiku, so it's hard
    > (7_\\    http://www.nothingisreal.com/  ><  To finish what you



    As far as I know they are.
    daniel, Aug 15, 2008
    #1
    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. Newsgroup - Ann
    Replies:
    0
    Views:
    395
    Newsgroup - Ann
    Aug 15, 2003
  2. Ravi
    Replies:
    8
    Views:
    10,258
    Mike Wahler
    Mar 6, 2004
  3. Paul
    Replies:
    1
    Views:
    501
    Jack Klein
    Nov 24, 2004
  4. Philipp
    Replies:
    21
    Views:
    1,111
    Philipp
    Jan 20, 2009
  5. pemo

    c99 multidimensional arrays contiguous?

    pemo, Mar 16, 2010, in forum: C Programming
    Replies:
    39
    Views:
    1,828
    David Thompson
    Mar 31, 2010
Loading...

Share This Page