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

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -