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

This is a discussion on Is there a limit to the size of 2-D arrays? within the C Programming forums, part of the General Programming Boards category; I was hoping to put some data into a large, two-dimensional array Code: int array[2319][2319]; I compile everything and it ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 02: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, 06:31 PM

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