can we change the size of the array? in other words, if we intialize the array size to a size, say 10 elements, later in the process we might have to store something more than 10 elements. Can the size of the array automatically expand?
Thanks.
Printable View
can we change the size of the array? in other words, if we intialize the array size to a size, say 10 elements, later in the process we might have to store something more than 10 elements. Can the size of the array automatically expand?
Thanks.
Not a standard array. In this case, you must create an array of a larger size, copy the elements over, and deallocate the old array (c++). In C using malloc/free, you can call realloc() to resize dynamically allocated memory.
In C++, it is better to use some sort of STL container, such as a vector. vectors will grow in size automatically.