2 Dimensional Array on heap

Hi everyone,

I have quite a large 2d array in my program, and I was wondering if it would be possible to move it to the heap to ensure it doesnt overflow the stack. It currently works but I might need to grab a few more kb from the stack, so I would prefer to store this array on the heap to clear up more room.

This is my current declaration:
1
2
3
4
5
...
using namespace std;

char word [30][235887];
...


I need to be able to access the contents letter by letter (the 30 corrisponds to the letters in the word, and the 235887 corresponds to the word count.)

Could anyone provide an example of what this would look like if allocated to heap using calloc() or new?

Also, how would i reference the variables after that for assigning and comparison.

Thanks so much, I could not find help on the matter of 2d arrays anywhere.

Ryan
Topic archived. No new replies allowed.