So, I have done my reading, and I understand what \*p++ means, and the basics of how \*target++ = \*source++ works. But I am mighty baffled by the results I am getting.

I want to copy the contents of an array into another. Simple enough, except if you look at how the contents of the array change as the program run, I don't have the first clue why this is the output...

**Here is my program:**

```
#include <stdio.h>

void printArray(int *array, int size){

    printf("{ ");
    for (int i = 0; i < size; ++i)
        printf("%d, ", array[i]);
    printf("}");

    printf("\n");
}

void copyArray(int *target, int *source, int size){

    for (int i = 0; i < size; ++i)
    {
        printf("Iteration #%d \n",i+1 );
        printf("Source Array: ");
        printArray(source, 5);

        printf("Target Array: ");
        printArray(target, 5);
        printf("\n");   

        *target++ = *source++; 
    }

}

int main(void){

    int source[] = {1, 2, 3, 4, 5};
    int target[5] = {0};

    copyArray(target, source, 11);

    return 0;
}

```

**And this is my output as it runs:**

Iteration #1  

Source Array: { 1, 2, 3, 4, 5, }  

Target Array: { 0, 0, 0, 0, 0, }

Iteration #2  

Source Array: { 2, 3, 4, 5, 32767, }  

Target Array: { 0, 0, 0, 0, 0, }

Iteration #3  

Source Array: { 3, 4, 5, 32767, -732409276, }  

Target Array: { 0, 0, 0, 0, 0, }

Iteration #4  

Source Array: { 4, 5, 32767, -732409276, 1442845569, }  

Target Array: { 0, 0, 0, 0, 0, }

Iteration #5  

Source Array: { 5, 32767, -732409276, 1442845569, 1583093720, }  

Target Array: { 0, 0, 0, 0, 1, }

Iteration #6  

Source Array: { 32767, -732409276, 1442845569, 1583093720, 32767, }  

Target Array: { 0, 0, 0, 1, 2, }

Iteration #7  

Source Array: { -732409276, 1442845569, 1583093720, 32767, -1844984375, }  

Target Array: { 0, 0, 1, 2, 3, }

Iteration #8  

Source Array: { 1442845569, 1583093720, 32767, -1844984375, 32767, }

Target Array: { 0, 1, 2, 3, 4, }

Iteration #9  

Source Array: { 1583093720, 32767, -1844984375, 32767, -1844984375, }  

Target Array: { 1, 2, 3, 4, 5, }

**So a couple of immediate questions I have are:**
1) when I call the function I pass it "target" which is a pointer to the first element of the array. Why does my target array start filling from its last position?

2)I don't have any code in there, at least not any voluntary code, that modifies the values of my "source" array. Why are those changing?

3)My first version of this program used a pointer to the last element of source to stop the loop inside copyArray, but then while running gdb I noticed it was taking more iterations to return the function than there are elements in the array, and I got curious. By trial and error I discovered it takes 9 iterations of the loop inside copyArray() to fully copy "source" into "target". Why is that? 

Any thoughts on the matter?

\*edited for readability