aboutsummaryrefslogtreecommitdiff
path: root/Project1/c_array.cpp
blob: d6b006de11dc171ef0cf60aee6778047fc1d77bc (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
35
36
37
38
39
40
41
42
43
#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 = new int[SIZE * 2];

	for (auto i = 0u; i < SIZE*2; ++i)
	{
		newArray[i] = array[i];
		
	}
	delete[] array;
	array = newArray;
	//memset(array, 0, SIZE * sizeof(array[100]));
	//memset(array, 0, SIZE * sizeof(array));
	SIZE *= 2;

	for (auto i = 101u; i < SIZE; ++i)
	{
		array[i] = 0;
	}


	PrintArray(array, SIZE);
}

void PrintArray(int* array, size_t size)
{
	for (auto i = 0u; i < size; i++)
	{
		cout << "array[" << i << "] = " << array[i] << endl;
	}
	cout << endl;
}