Learn Computer Science programming - C# and C++ Algorithms


Copy array to array

Copies one array to the other. This examples copies 10 elements. There is no element array1[10], but it is legal to compute a pointer to this (nonexistent) element, as long as we never try to fetch or store the value that it points to.
int array1[10], array2[10];
int *ip1  = &array1[0]

int *ip2 = &array2[0];
int *ep = &array1[10];

for(ip1; ip1 < ep; ip1++)
     *ip2++ = *ip1;