Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array size

Status
Not open for further replies.

nbgoku

Programmer
May 25, 2004
108
US
if i set my array size to be [6], can i change it to [24] later on or is this not allowed with arrays?
 
It's not allowed with arrays, but you can do it using memory allocation.

The initial array is created like this.
Code:
int *array;
array = new int[6];

Throw away the old array of 6 elements and make it 24.
Code:
delete [] array;
array = new int[24];

--
 
I strongly recommend looking up the STL vector class instead of using dynamically allocated arrays directly. It will simplify things greatly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top