array bounds overflow

This is a discussion on array bounds overflow within the C Programming forums, part of the General Programming Boards category; I have this source with the fragment attached. When i try to compile it with VC6 it gives me an ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    2

    array bounds overflow

    I have this source with the fragment attached. When i try to compile it with VC6 it gives me an "array bounds overflow" error for every line in that fragment. So, any ideas how to get rid of that error? because i dont have a ........ing clue...

    Code:
    CHAR                  Pattern[NUM_DATA][Y][X]  = { { "O O O O O ",
                                                         " O O O O O",
                                                         "O O O O O ",
                                                         " O O O O O",
                                                         "O O O O O ",
                                                         " O O O O O",
                                                         "O O O O O ",
                                                         " O O O O O",
                                                         "O O O O O ",
                                                         " O O O O O"  },
    
                                                       { "OO  OO  OO",
                                                         "OO  OO  OO",
                                                         "  OO  OO  ",
                                                         "  OO  OO  ",
                                                         "OO  OO  OO",
                                                         "OO  OO  OO",
                                                         "  OO  OO  ",
                                                         "  OO  OO  ",
                                                         "OO  OO  OO",
                                                         "OO  OO  OO"  },
    
                                                       { "OOOOO     ",
                                                         "OOOOO     ",
                                                         "OOOOO     ",
                                                         "OOOOO     ",
                                                         "OOOOO     ",
                                                         "     OOOOO",
                                                         "     OOOOO",
                                                         "     OOOOO",
                                                         "     OOOOO",
                                                         "     OOOOO"  },
    
                                                       { "O  O  O  O",
                                                         " O  O  O  ",
                                                         "  O  O  O ",
                                                         "O  O  O  O",
                                                         " O  O  O  ",
                                                         "  O  O  O ",
                                                         "O  O  O  O",
                                                         " O  O  O  ",
                                                         "  O  O  O ",
                                                         "O  O  O  O"  },
    
                                                       { "OOOOOOOOOO",
                                                         "O        O",
                                                         "O OOOOOO O",
                                                         "O O    O O",
                                                         "O O OO O O",
                                                         "O O OO O O",
                                                         "O O    O O",
                                                         "O OOOOOO O",
                                                         "O        O",
                                                         "OOOOOOOOOO"  } };

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    What is NUM_DATA, Y, and X

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    Keep in mind that X will have to be at least 11 to make room for the string terminator.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    2
    NUM_DATA, Y, X are constants

    Code:
    #define NUM_DATA      5
    #define X             10
    #define Y             10
    but the problem was with a string terminator. I made it this way:

    Code:
    CHAR                  Pattern[NUM_DATA][Y][X+1]  = { { "O O O O O "....
    and everything works now. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 08:25 PM
  2. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 01:20 PM
  3. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-12-2004, 12:15 AM
  5. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 05:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21