Thread: 2D Arrays: Column/Row Order

  1. #1
    Registered User
    Join Date
    May 2003

    Exclamation 2D Arrays: Column/Row Order

    I've noticed something odd in most of the books/tutorials I've read that deal with 2D arrays, including the current book I'm reading, Tom Swan's C++ Primer (1992).

    From what I've read, in C++, the standard way to order the indicies is row#, column#.

    The problem I have with that is that I think of coordinates in terms of (X, Y). Picking the ROW number first is effectively the same as picking the Y-coordinate; picking the column number is the same as picking the X-coordinate. This means that the coordinates are (Y, X), not (X, Y).

    I find this confusing, and so I use (X, Y). The question is: Does this matter? If I order my array (x, y) instead of (y, x), will others be confused by my code? Which way should I use?


  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Use whatever you like, as long as you use it that way consistently. There is no standard way of doing it (some libraries will do it one way, some the other, though this is usually a hidden implementation detail). If you think it might be confusing to someone (which I doubt), just put a comment in.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Large 2D Array's Problem
    By kas2002 in forum C Programming
    Replies: 4
    Last Post: 05-25-2009, 12:42 PM
  2. Help with 2d arrays
    By thamiz in forum C Programming
    Replies: 25
    Last Post: 05-25-2008, 05:06 AM
  3. 2D Array's, assigning chars.
    By gman89 in forum C Programming
    Replies: 9
    Last Post: 04-26-2008, 11:03 PM
  4. 2D arrays programming, please help
    By mfskratch in forum C Programming
    Replies: 4
    Last Post: 11-01-2007, 12:41 PM
  5. 2D Dynamically allocated pointer arrays
    By Lionmane in forum C Programming
    Replies: 37
    Last Post: 06-11-2005, 10:39 PM