Arrays in C++

limitations regarding array size in C++

Page 1 of 1

2 Replies - 2059 Views - Last Post: 06 April 2006 - 06:39 AM Rate Topic: -----

#1 lijojacobcs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 09-March 06

Arrays in C++

Posted 06 April 2006 - 01:44 AM

In one of my codes , the array size is given as 15000 . But i need an array of size more than 50,000 . But when I set the array size as 50,000 or above , a runtime error is occurring (exiting from the application) .
Is there any limitations regarding array size in C++?
I cannot use vectors since i have to rewrite almost a huge party of the code.
Is This A Good Question/Topic? 0
  • +

Replies To: Arrays in C++

#2 sontek  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 283
  • Joined: 13-September 01

Re: Arrays in C++

Posted 06 April 2006 - 01:47 AM

I'm not sure about a C++ specific limitation (I don't code in C++) but creating that large of an array means it needs to allocate that much memory for your application, which i'm sure any PC/OS will not be thrilled about it :P
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Arrays in C++

Posted 06 April 2006 - 06:39 AM

The problem is not a limit on the size of arrays in C++...the problem occurs due to stack size limits in the operating system. Each OS/computer architecture can by different, and will limit the amount of space that can be allocated directly upon declaration. To deal with this, you can either modifythe memory limit settings on your OS, or deal with it through code by dynamically allocating memory as it is required by the program.

There is an introduction to dynamic memory allocation here:
http://www.cplusplus...al/dynamic.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1