Hi,
if you take a pencil and a sheet of paper you will see what happens.
Before you had 10 items in your array (0 ... 9) now it seems you have 11 items (0 ... 10).
There are several (obvious) problems with your code.
To avoid confusion let´s take this code from post #1
Code:
temp = array4[0];
for (n=1; n<8; n++)
{
array4[j-1] = array[j];
}
array[9] = temp;
You are using the folowing array items:
* array4[0]
* array4[1]
* array4[2]
* array4[3]
* array4[4]
* array4[5]
* array4[6]
* array4[7]
(* array4[8] never used in your code)
* array4[9]
--> you see this are 10 items, but you talk about
9 digits only. How do you handle this?
temp = array4[0];
--> this is OK
for (n=1; n<8; n++)
--> Now you use variable "n" to count from 1 to 7
array4[j-1] = array[j];
--> here you use varaible
"j" but not variable "n".
you want to perform these operations: (but to do this you first need to change "j" to "n"
* array4[0] ... array4[1]
* array4[1] ... array4[2]
* array4[2] ... array4[3]
* array4[3] ... array4[4]
* array4[4] ... array4[5]
* array4[5] ... array4[6]
* array4[6] ... array4[7]
array[9] = temp;
--> this is OK.
this is what your code does so far.
--> but why don´t you update
* array4[7]
* array4[8]
???
******
Don´t forget to initialize the data properly. Especially don´t forget to initialize ALL array items when a new value is written to the array.
******
I recommed to use a trace tool for your code. And a sheet of paper and a pencil to write down the data values.
Klaus