diff options
| author | Connor McDowell <[email protected]> | 2024-02-15 17:14:12 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-15 17:14:12 -0800 |
| commit | 16cc25c98bfa077ee8f0b231f52f914c093fed22 (patch) | |
| tree | 7e0b288d3ba6d1828a428c2be020c1970aed83e9 /Project1/c_array.cpp | |
| parent | print and double created (diff) | |
| download | in-class-exercise-12-connormcdowell275-16cc25c98bfa077ee8f0b231f52f914c093fed22.tar.xz in-class-exercise-12-connormcdowell275-16cc25c98bfa077ee8f0b231f52f914c093fed22.zip | |
included memset from string.h in c_array.cpp
Diffstat (limited to 'Project1/c_array.cpp')
| -rw-r--r-- | Project1/c_array.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Project1/c_array.cpp b/Project1/c_array.cpp index f504839..1423273 100644 --- a/Project1/c_array.cpp +++ b/Project1/c_array.cpp @@ -1,27 +1,31 @@ #include <iostream> #include <ostream> #include "c_array.h" +#include <string.h> using std::cin; using std::cout; using std::endl; -void DoubleArraySize(int*& array, size_t size) +void DoubleArraySize(int*& array, size_t SIZE) { - int* newArray = nullptr; - newArray = new int[size * 2]; + int *newArray = new int[SIZE * 2]; - for (auto i = 0u; i < size; ++i) + for (auto i = 0u; i < SIZE*2; ++i) { newArray[i] = array[i]; + } delete[] array; array = newArray; - size *= 2; + + SIZE *= 2; + + PrintArray(array, SIZE); } void PrintArray(int* array, size_t size) |