Yeah, I tried it a few times, and it didn't work.
Like for example:
current array...
4,23,65,34,82,37,12,17,24,36,82,51
user input: 2
34,82,37,12,17,24,36,82,51 (It deletes the first 3 numbers, but I don't want that)
instead of
4,23,34,82,37,12,17,24,36,82,51 (65 gets deleted from 2)
Here is my removeAt function:
int removeAt (int numbers[], int length, int index)
{
index = 0;
cout<<endl;
cout<<"There are "<<length<<" item(s) in the list (position 0 through 11)"<<endl;
cout<<"Enter the position of the item to be removed."<<endl;
cout<<"Enter 0 for the first item and so on: ";
cin>>index;
do // keeps looping until the user puts in correct information
{
if (index > length)
{
cout<<endl;
cout<<"!!!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!"<<endl;
cout<<endl;
cout<<"The current array..."<<endl;
for (int i = 0; i<length; i++)
{
cout<<numbers[i]<<" ";
}
cout<<endl;
cout<<endl;
cout<<"!!!! Index out of Range !!!!"<<endl;
cout<<"There are "<<length<<" item(s) in the list (position 0 through 11)"<<endl;
cout<<"You entered position "<<index<<", which is OUT OF RANGE."<<endl;
cout<<"Enter the position of the item to be removed."<<endl;
cout<<"Enter 0 for the first item and so on: ";
cin>>index;
cout<<endl;
}
}
while(index > length);
cout<<"After removing the item at position "<<index<<", array is..."<<endl;
cout<<endl;
cout<<"The current array..."<<endl;
for (int i = index; i < length; i++)
{
numbers[i] = numbers[i+1];
cout<<numbers[i]<<" ";
}
cout<<endl;
cout<<endl;
cout<<"************************************************************";
cout<<endl;
cout<<endl;
}