Size of array in Visual C++ Express

Dear all,

I'm having trouble setting an array of 30,000 rows and 3 columns in Visual C++ EXpress 2010.

If I set the rows to 20,000 is fine but whren I use 30,000 or greater then it crashes.

Do you know how to increase the size of the arrays? Is this an issue from the Express compiler?

Best regards,

Leandro
It could be that what you're trying to do is just too big for the stack.
The stack is a part of your RAM that is relatively small.

For big arrays you will have to use the "heap", which is for dynamically allocated memory.

so instead of int my_array[30000*3];
you'd have to do...
int* my_array = new int[30000*3];
...and then delete the data once you're done with it
delete [] my_array;

BETTER SOLUTION:
Use the standard library's std::vector
http://en.cppreference.com/w/cpp/container/vector
1
2
#include <vector>
std::vector<int> my_array(30000*3);

use [] operator to access elements just like a regular array.
my_array[0] = 5;
And you don't have to worry about deleting the data, it is done for you.
Last edited on
Thanks very much Ganado!! I'll try this one.
Topic archived. No new replies allowed.