c++ - error while declaring double array of size 150000? -


this question has answer here:

i developing code in there need declaring array of double of size 150000 , when 1 array declared code running successfully.if declare 2 arrays while execution terminates throwing exception.

code :  double a[150000]; double b[150000]; 

if declare executes perfectly.if declare both , b terminates. can suggest how resolve this?

the 2 arrays overflowing stack (assuming local variables). dynamically allocate memory arrays instead, using std::vector manage memory you:

std::vector<double> a(150000); std::vector<double> b(150000); 

even though std::vector instances on stack, std::vector dynamically allocates memory internally data on heap, avoiding stack overflow.


Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -