Oct 2, 2004 #1 nbgoku Programmer Joined May 25, 2004 Messages 108 Location 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?
if i set my array size to be [6], can i change it to [24] later on or is this not allowed with arrays?
Oct 2, 2004 #2 Salem Programmer Joined Apr 29, 2003 Messages 2,455 Location GB 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]; -- Upvote 0 Downvote
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]; --
Oct 3, 2004 #3 timmay3141 Programmer Joined Dec 3, 2002 Messages 468 Location US I strongly recommend looking up the STL vector class instead of using dynamically allocated arrays directly. It will simplify things greatly. Upvote 0 Downvote
I strongly recommend looking up the STL vector class instead of using dynamically allocated arrays directly. It will simplify things greatly.
Oct 4, 2004 #4 mingis Programmer Joined Jan 23, 2002 Messages 475 Location LT realloc() in oldtimer style Upvote 0 Downvote