程序内容:
初始化一个Double类型的数组,把该数组的内容拷贝至其他三个数组中,分别使用数组表示法和指针表示法。
程序为C Primer Plus第十章第二题的答案示例
附:程序代码为本人亲自编写,并非书内标准答案,仅供参考。
如果程序有任何bug或者有好的建议,可以在评论区留言,或者私信。
程序源代码:
#include<stdio.h>
void copy_arr(double target[],const double source[],int n); //拷贝第一个数组
void copy_ptr(double *target,const double *source,int n); //用指针表示法拷贝
void copy_ptrs(double *target,const double *source, double *last); //用末尾指针表示结束
int main(void)
{
double source[5]={
1.1, 2.2, 3.3, 4.4, 5.5};
double target1[5];
double target2[5];
double target3[5];
int count;
copy_arr(target1,source,5);
copy_ptr(target2,source,5);
copy_p