-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize.cpp
More file actions
27 lines (23 loc) · 755 Bytes
/
Copy pathresize.cpp
File metadata and controls
27 lines (23 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* TODO: write a function to resize a dynamically allocated array.
* Prototype is given below. Remember: the basic steps are as follows:
* 1. Allocate a new chunk of memory of the desired size.
* 2. Copy elements from the old array to the new one.
* 3. Free the old one (delete).
* 4. Redirect the pointer to the new array.
* NOTE: your function should work even if newsize < oldsize.
* */
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
/* your answer goes here... */
void resize(int*& A, size_t oldsize, size_t newsize)
{
}
int main()
{
/* TODO: use your resize function to read an arbitrary number of integers
* from stdin. Each time you run out of space, double the array size. */
return 0;
}
// vim:foldlevel=2