aboutsummaryrefslogtreecommitdiff
path: root/Project1/c_array.cpp
blob: f5048390e1816d861a11a968f20c13551a417d46 (plain) (blame)
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
28
29
30
31
32
33
34
#include <iostream>
#include <ostream>
#include "c_array.h"

using std::cin;
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;
}