Deleting from Array
- Removing an element from an array is called deleting
- After deleting an element the space must not be empty in an array so shift the bits accordingly
- The index should not be beyond the array
int Delete(struct Array *arr, int index) {
int x = 0;
int i;
if (index >= 0 && index < arr->length) {
x = arr->A[index];
for (i = index; i < arr->length - 1; i++) {
arr->A[i] = arr->A[i + 1];
}
arr->length--;
return x;
}
return 0;
}