So i'm trying to insert a number into an array in ascending order and then print the array by using only pointer notation. I tried doing this by finding the position of where the number would be inserted and then I try to store all the values at that position and after in positions further down the array. Then I want to insert the number at it's proper position and then move all of the numbers back to their position+ 1. However I think I am missing something in my pointer notation because none of my checks are showing up, so my for loops arent even being used. Any help or advice would be appreciated.
using namespace std;
int main(int argc, char *argv[])
{
int spot; // spot holder for the added number
int *pointer = NULL;
cout << "How many numbers do you want in your array" << endl;
int input;
cin >> input;
pointer = new int[input * 2 ];
for (int index = 0; index < input; index ++)
{
cout << "Enter integer number" << index + 1 << endl;
cin >> *(pointer + index);
}
for (int index = 0; index < input; index ++)
{
cout << *(pointer + index);
}
cout << endl;
cout << "What number would you like to add?" << endl;
int added;
cin >> added;
for (int index = 0; added < *(pointer + index); index++)
{
spot = index;
cout << "check .5: " << spot;
}
for (int index = spot; index < input + 1; index++)
{
*(pointer + input + index) = *(pointer + index); //& added
cout << "check 1: " << *(pointer + input + index);
}
*(pointer + spot) = added;
for (int index = spot + 1; index < input + 1; index++)
{
*(pointer + index) = *(pointer + index + input);
cout << "check 2" ;
}
for (int index = 0; index < input + 1; index ++)
{
cout << *(pointer + index);
}
cout << endl;
}