This is elementary, but my googling just doesn't cut it. I know I have to do something else to shift the values of an array one by one, but the below coding gives me the same values for items[k] to items[infinity] all equaling items[k]. What I don't understand is how to preserve the original k+1 value while I copy the k value into the k+1 slot.
if ( i < numItems) //if i is inside the used boundaries of the array
{
for (int k = i; k < numItems; k++) //shift the array values from point i
{
double temp = 0.0;
temp = items[k];
items[k+1] = temp;
}
items[i] = value; //and insert value into i
}
Does it has to be a recursive method?