Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Newbie: multidimensional arrays problem
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 24th April 22:20
tomweston_usenet
External User
 
Posts: 1
Default Newbie: multidimensional arrays problem


I'm quite a novice with c++ so this is probably more a language
issue than a compiler/system one but I've been writing a program
and have just included some multidimensional arrays that make
for a strange effect that I can't explain.

As the program currently stands it looks i outline like this

int main()
{

cout << " currently here\n";

const int xmax=1200;
const int tmax=51;

double price[tmax][xmax+1];
double reslevel[tmax][xmax+1];

// lots of code that doesn't involve price or reslevel

return 0;

}

This compiles and when run doesn't print anything.
If I comment out the two lines dimensioning the multi-dim
arrays, it compiles and runs fine.
If I change the data type of the arrays to int or float,
it compiles OK and runs fine.

This seems a bit bizarre to me, but as I say, I'm not experienced
with C++.

Any ideas?

Many thanks,
Tom
  Reply With Quote


  sponsored links


2 24th April 22:20
hans-bernhard broeker
External User
 
Posts: 1
Default Newbie: multidimensional arrays problem


The problem almost certainly is caused by the exact size of your
arrays. Make them a little larger, and odds are your program will
crash immediately on startup. Make them a little smaller and it'll
work fine, or maybe crash later. Move them outside the main()
function, and the problem will vanish for good. Replace them by
dynamically allocated arrays (using the 'new' operator), and it'll
vanish, too, but programming becomes a bit more tricky.

Check out the DJGPP FAQ, Q 15.9, "How much stack can I have in DJGPP
programs?", details.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666