diff options
| author | Connor McDowell <[email protected]> | 2024-02-15 16:52:41 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-15 16:52:41 -0800 |
| commit | ac9e104567f6989d9959d9cf16019adb926a59c2 (patch) | |
| tree | 75ed3932ea80352c5fe437580bf698b42aa07c5e /Project1/c_array.cpp | |
| parent | links created, usings created (diff) | |
| download | in-class-exercise-12-connormcdowell275-ac9e104567f6989d9959d9cf16019adb926a59c2.tar.xz in-class-exercise-12-connormcdowell275-ac9e104567f6989d9959d9cf16019adb926a59c2.zip | |
print and double created
Diffstat (limited to 'Project1/c_array.cpp')
| -rw-r--r-- | Project1/c_array.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Project1/c_array.cpp b/Project1/c_array.cpp index fd64a39..f504839 100644 --- a/Project1/c_array.cpp +++ b/Project1/c_array.cpp @@ -7,3 +7,28 @@ using std::cout; using std::endl; +void DoubleArraySize(int*& array, size_t size) +{ + int* newArray = nullptr; + + newArray = new int[size * 2]; + + for (auto i = 0u; i < size; ++i) + { + newArray[i] = array[i]; + } + delete[] array; + + array = newArray; + + size *= 2; +} + +void PrintArray(int* array, size_t size) +{ + for (auto i = 0u; i < size; i++) + { + cout << "array[" << i << "] = " << array[i] << endl; + } + cout << endl; +}
\ No newline at end of file |