Thread: Question about arrays

  1. #1
    i dont know Vicious's Avatar
    Join Date
    May 2002

    Question about arrays

    There has been alot of talk about array's recently and it got me thinking.

    Does a multidimensional array have any advantages/disadvantages over a non-multidimensional one?


    to store things like tilemaps you could do
    int  array[20][20];
    Or you could just
    int array[400];
    So in the end, does one method have any advantages over the other?

  2. #2
    Registered User manofsteel972's Avatar
    Join Date
    Mar 2004
    The computer treats multidimensional arrays as a single huge array. You are basically using pointer arithmatic to access the elements in the array either you single step by just incrementing through each element or you add an offset to increment by row or column etc. The main advantage is in the ease of use. It is alot easier to just access an array by its elements especially when you get to 3+ dimensions because the pointer aritmatic can get ugly and confusing.
    "Knowledge is proud that she knows so much; Wisdom is humble that she knows no more."
    -- Cowper

    Operating Systems=Slackware Linux 9.1,Windows 98/Xp
    Compilers=gcc 3.2.3, Visual C++ 6.0, DevC++(Mingw)

    You may teach a person from now until doom's day, but that person will only know what he learns himself.

    Now I know what doesn't work.

    A problem is understood by solving it, not by pondering it.

    For a bit of humor check out xkcd web comic

  3. #3
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Thank you,

    I wasnt really sure how the computer dealt with them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about arrays.
    By Kelvie in forum C++ Programming
    Replies: 3
    Last Post: 09-17-2007, 05:32 AM
  2. A question concerning character arrays
    By ellipses in forum C Programming
    Replies: 3
    Last Post: 03-08-2005, 08:24 PM
  3. Replies: 6
    Last Post: 04-26-2004, 10:02 PM
  4. Question about char arrays
    By PJYelton in forum C++ Programming
    Replies: 5
    Last Post: 10-21-2003, 12:44 AM
  5. Question about arrays?? PLease read..
    By foofoo in forum C Programming
    Replies: 3
    Last Post: 06-24-2002, 02:40 PM