Consider the situation where there are three elements in your array, and index is 1. So
i
goes from 1 to 1 (i.e. less than 2 (3-1)). So
for (i = 1; i < 2; i++)
{
arr[1] = arr[2];
}
Your code does not actually remove anything, it just moves all the elements after the one pointed to by
index
. And the last one in the loop is duplicated.