Archived

This topic is now archived and is closed to further replies.

change size of an array

This topic is 5587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You can''t do that with built in arrays.
In C++, check out the std::vector class.
In C, look into dynamic allocation using malloc, realloc, free. realloc is a bit dodgy because it can move data about.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share this post


Link to post
Share on other sites
You have to do (for int):

  
int myArray[5];
int newArray[10];

memcpy(newArray, myArray, 5 * sizeof(int));

// if you allocated myArray with new then you can delete it now




schiggl

Share this post


Link to post
Share on other sites