Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,618 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 995 people online right now. Registration is fast and FREE... Join Now!




Arrays in C++

 
Reply to this topicStart new topic

Arrays in C++, limitations regarding array size in C++

lijojacobcs
post 6 Apr, 2006 - 12:44 AM
Post #1


New D.I.C Head

*
Joined: 9 Mar, 2006
Posts: 5


My Contributions


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.
User is offlineProfile CardPM

Go to the top of the page

sontek
post 6 Apr, 2006 - 12:47 AM
Post #2


D.I.C Regular

Group Icon
Joined: 13 Sep, 2001
Posts: 283



Thanked 1 times

Dream Kudos: 85
My Contributions


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 tongue.gif
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 6 Apr, 2006 - 05:39 AM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


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.com/doc/tutorial/dynamic.html
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 03:13AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month