psasidisrcum
February 28th, 2005, 02:26 PM
Hi all,
I'm creating a simple Notepad-like application that allows basic editing of text. I'm assuming that the characters would have to be stored in an array, either a 2D wchar_t array, or a 1D wstring array (would one be better than the other..?)
How does one deal with the problem of allocating enough memory for the array?
Since it's not possible to know, in advance, how many lines of characters the array will have to store, do I have to dynamically allocate a new array each time the enter key is pressed, copy the contents of the old array to the new array, and delete the old array? This strikes me as a somewhat inefficient method.
More importantly though, would I soon run out of memory using such a method? ie. would this method support thousands of lines of characters? I don't know much about what VC++ will let me get away with, as far as array sizes go.
Someone must've had some experience with this. Thanks in advance for any help!
I'm creating a simple Notepad-like application that allows basic editing of text. I'm assuming that the characters would have to be stored in an array, either a 2D wchar_t array, or a 1D wstring array (would one be better than the other..?)
How does one deal with the problem of allocating enough memory for the array?
Since it's not possible to know, in advance, how many lines of characters the array will have to store, do I have to dynamically allocate a new array each time the enter key is pressed, copy the contents of the old array to the new array, and delete the old array? This strikes me as a somewhat inefficient method.
More importantly though, would I soon run out of memory using such a method? ie. would this method support thousands of lines of characters? I don't know much about what VC++ will let me get away with, as far as array sizes go.
Someone must've had some experience with this. Thanks in advance for any help!