Thread: 2d array problem

  1. #1
    Registered User
    Join Date
    Sep 2003

    2d array problem

    Hi, I am new to Visual C++.

    I have a 2d array in my function.
    char array[MAX][MAX];

    I then fill in the contents of the array, say, like this:

    Now when I run the debugger and want to view the contents of the 2D array,
    I don't see them.
    If I type this in my watch window:
    it says "error: index 0 out of bounds for pointer/array 'array' "
    same error comes up if I type something like this in my watch window:

    Can anyone tell me what I am doing wrong? I really need to be able to view contents of my 2d array!

    Thanks for any ideas.

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    ok, lets start with the fact that this is not visual... it maybe the compiler, but it's not win api or anything like it.
    your code is a simple ansi standart c/c++, so the question is not really part of this board.

    but anyway, your code is fine, and should compile and give you the right result.
    I don't really use ms visual, so I can't really help you with the "watch", but there is a much simple way to view the array:

    printf("%s", array[0]);

    I hope that helps.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with 2D array
    By Stlcardinal50 in forum C++ Programming
    Replies: 1
    Last Post: 04-23-2009, 03:23 PM
  2. 8 Queens, problem with searching 2D array
    By Sentral in forum C++ Programming
    Replies: 35
    Last Post: 03-11-2009, 04:12 PM
  3. Problem with a 2D array.
    By earth_angel in forum C++ Programming
    Replies: 4
    Last Post: 08-20-2005, 11:28 AM
  4. Copying from one 2d array to another....with a twist
    By Zildjian in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2004, 07:39 PM
  5. 2d array problem with vc++
    By LiLgirL in forum C++ Programming
    Replies: 10
    Last Post: 03-16-2004, 08:17 PM