Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Resize(int arr[], int newSize)
- {
- if(arr != NULL )
- delete[] arr;
- arr = new int[newSize]();
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- const int InitialSize = 5, NewSize = 10;
- //Initialize Array
- int *arr = NULL;
- arr = new int[InitialSize]();
- //Resize arr to new Size
- Resize(arr, NewSize);
- //Assign Values for new array here
- for(int i = 0;i < NewSize; i++)
- {
- arr[i] = i;
- }
- //Free Memory
- if(arr)
- {
- delete[] arr;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement