diff options
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 |