for(int i=0;i<10;i++)
{
int tempValue=LTENC[i];
int copyLocation = i + 1;
LTENC[copyLocation]=tempValue;
i++;
}
Logically I ask myself where is the first command? is it LTEN[0] or [9]:
lets say LTEN[0] = 100
now using your code and going thru the first iteration:
tempValue = 100
copyLocation = i+1 , which is 1
then you do LTENC[1]=tempValue;
therefore you assigned LTENC[1] the value that the old LTEN[0] had.
then you increment...
the problem is, that the next loop simply reassigns...
LTENC[1] = 100
now using your code and going thru the next iteration:
tempValue = 100
copyLocation = i+1 , which is 2
then you do LTENC[2]=tempValue;
therefore you assigned LTENC[2] the value that the old LTENC[1] had.
this problem will repeat itself.
What you would want to do is something like:
-
for(int i=0;i<9;i++) // NOTICE I lowered the max...
-
{
-
LTENC[i]=LTENC[i+1];
-
i++;
-
}
-
LTENC[9]= newval;
-
lets assume from 0 to 9 contains 10,11,12,13...etc.
iterating for the first few we get...
LTENC[0] = 11
LTENC[1] = 12
...
LTENC[9] = newval
the next time they enter a new value... each element in the array would move down 1.
I hope that helps, if I made a mistake please let me know.