aboutsummaryrefslogtreecommitdiff
path: root/Project1/c_array.cpp
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-15 16:52:41 -0800
committerConnor McDowell <[email protected]>2024-02-15 16:52:41 -0800
commitac9e104567f6989d9959d9cf16019adb926a59c2 (patch)
tree75ed3932ea80352c5fe437580bf698b42aa07c5e /Project1/c_array.cpp
parentlinks created, usings created (diff)
downloadin-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.cpp25
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