// ex_ch10_2.c
#include <stdio.h>
#define SIZE 5

void show_arr(const double ar[], int n);
void copy_arr(const double src[], double dest[], int n);
void copy_ptr(const double src[], double dest[], int n);

int main(void)
{
	const double source[SIZE] = {1.1, 2.2, 3.3, 4.4, 5.5};
	double target1[SIZE];
	double target2[SIZE];

	show_arr(source, SIZE);
	copy_arr(source, target1, SIZE);
	show_arr(target1, SIZE);
	copy_ptr(source, target2, SIZE);
	show_arr(target2, SIZE);
	
	return 0;
}

void copy_arr(const double src[], double dest[], int n)
{
	int i;
	
	for (i = 0; i < n; i++)
		dest[i] = src[i];
}

void copy_ptr(const double src[], double dest[], int n)
{
	int i;
	
	for (i = 0; i < n; i++)
		*(dest + i) = *(src + i);
}

void show_arr(const double ar[], int n)
{
	int i;
	
	for (i = 0; i < n; i++)
		printf("%.1f  ", ar[i]);
	putchar('\n');
}
