본문 바로가기

TEST/자료구조와 함께 배우는 알고리즘 입문(C언어)

<2> Q8. 자료구조와 함께 배우는 알고리즘 입문 (C언어)

#include <stdio.h>

void ary_copy(int a[], const int b[], int n)
{
	while (n--)
	{
		a[n] = b[n];
	}
}

int main(void)
{
	int a[3];
	int b[] = { 1,2,3 };
	ary_copy(a, b, 3);
	for (int i = 0; i < 3; i++)
		printf("a[%d] = %d\n", i, a[i]);
	return 0;
}