Re: maximum number of dimensions in C/C++ array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



andre maute wrote:

> Has somebody an idea where to find the maximum number
> of dimensions for declaring an array?
> How many are supported within GCC and how many are
> mandated by the standards?
> 
> e.g.
> 
> double v[n1][n2][n3];
> declares obviously a  3-dimensional array of doubles.

The problem is that declaring an array that way causes it to be
allocated on the stack, and the stack is not a good place to allocate
large amounts of memory.  You will almost certainly overflow the stack
trying to do this.  If instead you use malloc() and pointers, you can
allocate arrays to any arbitrary depth, bounded only by total available
memory.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux