Thread: what the the place for rows and cols in 2d array..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    what the the place for rows and cols in 2d array..

    arr[1] [2]

    what 1 represents

    what 2 represent

    where cols or rows go?

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Code:
    int nums[3][4] = {0, 1, 2, 3,
                      4, 5, 6, 7,
                      8, 9,10,11};
    
    printf("%d\n", nums[2][3]);
    //This will print 11
    
    printf("%d\n", nums[1][2]);
    //This will print 6
    
    printf("%d\n", nums[0][1]);
    //This will print 1
    but you could see that array declared like this
    Code:
    int nums[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
    Last edited by carrotcake1029; 12-18-2008 at 01:36 PM.

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    thanks

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    C uses row major order:

    Array[row][column]

    The only function I know of in C that uses column major order is the old
    gotoxy(column, row),

    Windows continues with that same order, in some screen oriented functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  2. Dynamically Allocating a 2D Array.
    By LightsOut06 in forum C Programming
    Replies: 17
    Last Post: 10-09-2005, 12:55 AM
  3. Dynamic 2d array
    By Mithoric in forum C++ Programming
    Replies: 8
    Last Post: 12-29-2003, 09:19 AM
  4. File I/O with 2D arrays
    By hypertension in forum C Programming
    Replies: 2
    Last Post: 02-04-2003, 08:47 AM
  5. Pointers and Arrays
    By Sean Gilbride in forum C Programming
    Replies: 3
    Last Post: 03-12-2002, 07:06 PM