Dynamically allocating arrays questions

Why is this program only printing out 3s instead of 1 2 3? I was to create an array without knowing the initial size and i thought i did that but i can't seem to get it to act normally. Also at the end it prints out a -842150451 what does that number represent?
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
#include <iostream>
using namespace std;


int main()
{

	int c = 0;
        int cC = 0;
	int *iPointer1 = NULL;
	int *iPointer2 = NULL;

	do
	{
		c++;
		cC++;

		iPointer1 = new int[c];
		for (int i = 0; i < c; i++)
		{
			iPointer1[i] = cC;
		}

		iPointer2 = new int[c + 1];
		for (int i = 0; i < c; i++)
		{
			iPointer2[i] = iPointer1[i];
		}
		iPointer2[c + 1] = cC;

	} while (c != 3);

	for (int i = 0; i < c + 1; i++)
	{
		cout << iPointer2[i] << " ";
	}
	delete[] iPointer1;
	delete[] iPointer2;
	return 0;
}
    
Topic archived. No new replies allowed.