Thread: Is there a limit to the size of 2-D arrays?

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    14

    Is there a limit to the size of 2-D arrays?

    I was hoping to put some data into a large, two-dimensional array
    Code:
    int array[2319][2319];
    I compile everything and it comes up with 0 errors and 0 warnings, but when I execute the file, it just crashes when it tries to declare the array. The program's fine for smaller 2-D arrays so I'm assuming there's a limit to how big the arrays can be.
    Does anyone know a way to get around this?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's possible you can get away with it if it's global, since you'll have a bit more room to play with. However, you'd be better off allocating it dynamically.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well that would depend on your OS and compiler, and whether there was any way to configure the default stack size a process is allowed to have.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  3. Help Understanding Passing Arrays To Functions
    By jrahhali in forum C++ Programming
    Replies: 7
    Last Post: 04-10-2004, 02:57 PM
  4. Arrays of user-defined size?
    By Captain_Penguin in forum C++ Programming
    Replies: 7
    Last Post: 09-12-2002, 04:07 PM
  5. size of integer arrays
    By steve8820 in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 07:31 PM