I apologize if the question is really easy... but I cannot figure out why I get an error message by my operating system (not the compiler, the program works if the array is say [50][50])
double x[1000][1000];
for (int i=0; i<100; i++)
{
for (int j=0; i<100; j++)
{
x[i][j] = i+j;
}
}
It is really weird since other programs like Matlab handle big 1000x1000 matrices without difficulties...
I am writing some code where I should make use of some 2-dimensional arrays of that size (ie.[1000][1000]) but I cant make it work...(though it works perfectly if I use 50x50 arrays)
Well your for loops are wrong since they only loop to 100 instead of 1000. What is the error that you are getting? What compiler? What OS? 1000*1000 = 1000000 which is 1 million. That is pretty big for a stack array but I don't know how big your stack is.
I am sorry the loops were meant t go up to 1000 but that s not quite the point since even the program
double x[1000][1000];
produces the same error....!!
The compiler is Dev-C++ and the error I get is not from the compiler but from Windows itself...
I get the usual message "an error as occurred with Untitled1.exe" and at the end I have the option to Notify the problem to Microsoft and I choose "Dont's send"...
let me ask a question then...how come Matlab can easily handle a 1000x1000 matrix whereas c++, which is much more powerful, cannot do such a thing?
All of the array things, a million doubles, are on the stack. The reason Matlab handles them is because of the way it is coded. The stack is way too much.
i am using double bc in the code i am writing those are decimals... actually they are probabilities, ie reals bw 0 and 1... you think there is a better type i can use..?
btw... i think that if i use the vector class in the std lib i can handle much bigger vectors