James wrote:
Hi,
I am using Visual C++ 6.0. I got a "stack overflow" error message when
running the program because of a "double array[500][500]". I have a
computer with 1GB memory. Can I extend the memory for the program
running? How?
It's not the "memory for the program running" it's the stack size
that is too small. <OT> You may adjust it via some compiler options,
I believe. </OT>.
Better than that, don't have this 4MB array allocated on stack
(which happens, for instance, if it's a local variable inside a
function) -- try going for dynamical allocation, using 'new' for
example. See your book's index for "new", "dynamical allocation",
and also the C++ FAQ-lite for how to handle two-dimensional
arrays using 'new'.
You might also consider using a
std::vector< std::vector <double> >
for storing your doubles.
HTH,
- J.