Maximum Number of Characters

Maximum Number of Characters

I’m reading approximately two million characters into an array. The max number of elements that Borland Turbo C++ 5.02 allows me is not enough. Can I declare this array to be a lot bigger or allocate more memory for this array?

The maximal possible size of an array depends on the OS you’re using and the compiler’s setting. If it’s DOS, you can’t allocate such a huge array on the stack, and even dynamic allocation might not succeed. The workaround is to split the array into smaller sub-arrays, each occupying 64k or so, and swap them into a disk file (modern operating systems do that automatically but DOS doesn’t).Alternatively, you can redesign your application so that it uses a smaller data structure.


Share the Post: