回复 10楼 qq1023569223
谢谢找到原因了
回复 11楼 荀减一
这个代码编译没错误,但是结果好奇怪。。。#include<stdio.h>
void copy_arr(double sourse[],double target1[],int n);
void copy_ptr(double sourse[],double target2[],int n);
int main()
{
int i;
double arr[5]={1.1,2.2,3.3,4.4,5.5};
double cop1[5]={0};
double cop2[5]={0};
copy_arr(arr,cop1,5);
copy_ptr(arr,cop2,5);
printf("the array after copy is:\n");
for(i=0;i<5;i++)
{
printf("%.1f",cop1[i]);
}
for(i=0;i<5;i++)
printf("the array after copy is %.1f\n",cop2[i]);
return 0;
}
void copy_arr(double sourse[],double target1[],int n)
{
double source[5];
int i;
for(i=0;i<5;i++)
{
target1[i]=source[i];
}
}
void copy_ptr(double sourse[],double target2[],int n)
{
double source[5];
double *pt;
int i,m;
pt=source;
for(i=0,m=0;i<5;i++)
{
target2[i]=*(pt+m);
m++;
}
}