![]() |
VOOZH | about |
In C++, the array of strings is useful for storing many strings in the same container. Sometimes, we need to change the size of this array. In this article, we will look at how to resize the array of strings in C++.
There is no way to directly resize the previously allocated memory. But we can create a new array, copy all the elements, and then delete the previous array using new and delete operators.
Old Array Elements: Apple Banana Cherry Date Fig New Array Elements: Apple Banana Cherry Date Fig kiwi dragonfruit
Instead of this type of array we can use dynamic std::vector of strings which by default enables dynamic resizing.