I was trying out a 2-dimensional integer array on a UNIX box. I hit up a 'Segmentation Fault' on trying to run it.
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
int matrix[2000][2000];
int i, j;
srand ( 1 );
for (i=0; i<2000; i++) {
for (j=0; j<2000; j++) {
matrix[i][j] = rand() %1000;
}
}
return 0;
}
But If I use an array of 10x10, everything seems to work properly. I was thinking of this : 'Did I hit up on the limit of the integer array?'
Do I need to use some other datatype? Uh, double/long/something of this sort ? I need to replicate a 2000x2000 matrix...