Instead of a, b, c to x, y, z, you should be using arrays. It might be helpful to throw a couple printf's in to see what is going on in places of interest.
Code:
#include <stdio.h>
int ptrcopy(int *src, int *dest, int len)
{
int result = 0;
while ( len > 0 )
{
int val = *src++;
*dest++ = val;
result ^= val;
len--;
}
return result;
}
int main()
{
int a[] = {0x123, 0x456, 0x789};
int x[] = {0x111, 0x222, 0x333};
int i;
for ( i = 0; i < 3; ++i )
{
printf("a[%d] = %x, x[%d] = %x\n", i, a[ i ], i, x[ i ]);
}
printf("result = %d\n", ptrcopy(a,x,3));
for ( i = 0; i < 3; ++i )
{
printf("a[%d] = %x, x[%d] = %x\n", i, a[ i ], i, x[ i ]);
}
return 0;
}
/* my output
a[0] = 123, x[0] = 111
a[1] = 456, x[1] = 222
a[2] = 789, x[2] = 333
result = 764
a[0] = 123, x[0] = 123
a[1] = 456, x[1] = 456
a[2] = 789, x[2] = 789
*/
The function ptrcopy copies from one array to another, calculates some sort of checksum (an LRC?), and returns the calculated result.