Code:
int arr[] = {1, 2, 3, 4};
arr[1] = 0; //2nd element deleted
After that, each element stays in the same order. The only difference is the second element is 0.
If what you mean is to re-arrange the array so that there is no empty space between the elements, you can go through the array and move each element one by one, or use memmove to do it.
Code:
const int arr_sz = 4;
for (int i = 0; i < arr_sz - 1; ++i)
{ if (arr[i] == 0)
arr[i] = arr[i + 1], arr[i + 1] = 0;
}
Or a simpler, faster way:
Code:
memmove(arr+1, arr+2, (arr+arr_sz) - (arr+2) );