Large 2 dimensional arrays

Does anyone know a way to create a very large 2 dimensional array. I am talking in the order of :
int sl[7000][5000];
I am new to C++. Also is there a better way than arrays to handle such a large amount of integers.

kkirk wrote:
[..] is there a better way than arrays to handle such a large amount of integers.

Yes: http://en.cppreference.com/w/cpp/container/vector
1
2
3
4
5
int main()
{
    static int sl[7000][5000] ; // static because stack space is limited
    // ....
}



If it is sparse, a sparse matrix can be used to save memory.

For instance, with Boost uBLAS http://www.boost.org/doc/libs/1_55_0/libs/numeric/ublas/doc/matrix_sparse.htm

1
2
3
4
5
6
7
#include <boost/numeric/ublas/matrix_sparse.hpp>

int main()
{
    boost::numeric::ublas::compressed_matrix<int> m(7000,5000) ;
    // ...
}

Thank you JLBorges & Caligulaminus
I add a static keyword before the int and it works. I looked into vectors and matrix and they are just a little beyond me at this early stage.
Thanks again.
Karl

Topic archived. No new replies allowed.