473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

stack overflow just because of a double array[500][500]?

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?

Looking forward to hearing from you!

Regards,

James
Jul 22 '05 #1
2 4231

"James" <me******@mail1.monash.edu.au> wrote in message
news:dc**************************@posting.google.c om...
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?


Possibly but how big the stack is something that your compiler specifies not
the C++ language. Ask in a compiler specific group for an ansewr to this
question.

But really you should use dynamic allocation, any of the methods I suggested
in response to your last post would be prefereable to trying to declare such
a huge array on the stack.

For instance

#include <vector>

std::vector<std::vector<double> > array(500);
for (int i = 0; i < 500; ++i)
array[i].resize(500);

is a simple way to give you a 500 by 500 2D array without blowing your
stack.

john
Jul 22 '05 #2
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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Moshe | last post by:
Scenario - IIS 5.0 WIN2K latest SP Application ASP. An ASP Page has a text area. When submitted calls SQL server 2K Stored Procedure to update a record. The field in the data base is of type...
11
by: Randell D. | last post by:
Folks I have a multi-dimensional array in javascript, as follows: gameRecord=new Array(500); gameRecord="FA Cup : 19 February 2005"; gameRecord="Arsenal v Sheff Utd, 12:30";...
25
by: Ashutosh Iddya | last post by:
Hi , I am performing an integer count of a particular operation in my program. After a sufficiently large value an overflow occurs. At the moment I have gone around the problem by declaring it...
4
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and...
9
by: Eric Webster | last post by:
I have a fairly simple VB.Net program I'm developing that listens to data coming over the internet and processes it. The data comes in as events - the app is idle until another chunk of data comes...
29
by: foker | last post by:
I have this problem where I have 2 text files, one with student name, id#, # of courses and course #, the second file has course name and course number. I want to make a multidimensional array that...
7
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char...
13
by: jm.suresh | last post by:
Hi, I have a program which literately finds the object that overlapping a point. The horizontal and vertical search are called recursively from inside each other. Is this way of implementation...
4
by: lightaiyee | last post by:
Dear Gurus, I would like to implement a function that computes the number of times a certain condition is met in a global array. For example, I have an global array of size 500. float array;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.