Using dynamic memory, I am trying to make a class that stores numbers in a dynamic array (so 123 would be arr[0] = 1, arr[1] = 2, arr[2] = 3) and be able to append digits (e.g. if the number stored is 123, you could add more digits.. 45 and the new number would be 12345).
Here's my code so far: How would I go about making an append function?
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int *exampleArray; //new array into exsistence
exampleArray = new int[5]; // dynamically allocates an array of 5 ints
for (int i = 1; i < 5; i++)
{
exampleArray[i] = i;
cout << exampleArray[i] << endl;
}
delete exampleArray; // deleted from exsistence
system("pause"); // to show the output
return 0;
}