#include <stdio.h>
void copy_ptrs(double *target3, double *source, int n);
int main(void)
{
double source[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
double target2[5];
double target3[5];
double * p_source;
double * p_target3;
p_source = source;
p_target3 = target3;
for(int i = 0; (p_source + i) < p_source + 5; i++)
{
*(p_target3++) = *(p_source++); //这里的计算结果是正确的。。?
printf("source[%d] = %.2f, target3[%d] = %.2f\n", i, source, i, target3);
}
printf("\n");
copy_ptrs(target2, source, 5);
return 0;
}
void copy_ptrs(double *target2, double *source, int n)
{
for(int i = 0; (source + i) < source + n; i++)
{
*(target2++) = *(source++); //error,???
printf("source[%d] = %.2f, target2[%d] = %.2f\n", i, source, i, target2);
}
return;
}
|