erase element from array c++ code example
Example 1: how to delete something in an array c++
delete myarray[elemen];
Example 2: delete index from array c++
const int SIZE = 9;
int arr[SIZE];
cout << "Enter numbers: \n";
for (int i = 0; i < SIZE; i++)
cin >> arr[i];
for (int i = 0; i < SIZE; i++)
cout << arr[i] << "\t";
cout << endl;
cout << "Enter Index U want to delete:\n";
int del;
cin >> del;
for (int i = del-1; i < SIZE; i++)
{
arr[del] = arr[del + 1];
del++;
}
for (int i = 0; i < SIZE - 1; i++)
cout << arr[i] << "\t";
cout << endl;