|
-
Sep 30th, 2006, 12:28 PM
#1
Thread Starter
Lively Member
is the size of the array changeable
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.
-
Sep 30th, 2006, 02:34 PM
#2
Re: is the size of the array changeable
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.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|