i try to reduce the length of an array after delete element i have try array:
int* arr = new int[5];
for (int i = 0; i < 5; i++) {
arr[i] = i;
}
and the function:
void del1(int* arr, int n) {
int pos = 0;
for (int i = 0; i < n; i++) {
if (arr[i] == 3) {
pos = i;
}
}
for (int i = pos; i < n - 1; i++) {
arr[i] = arr[i + 1];
}
arr[n - 1] = 0;
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
}
is there a way to reduce the length of the array that sent to the function?
del1function?