[ create a new paste ] login | about

Link: http://codepad.org/2B5k45cI    [ raw code | output | fork ]

nel - C, pasted on Oct 10:
#include <stdio.h>


void CopyNumbers(int *first, int *second, unsigned MAXN);

unsigned MAXN = 10; // setting up max numbers of number to be copied.

int main(void)
{
	int first[10] = {5, 12, 23, 52, 4, 61, 23, 1, 9, 10, 2};
	int second[10];

	CopyNumbers(first, second, MAXN);

	return 0;
}

void CopyNumbers(int *first, int *second, unsigned MAXN)
{
	unsigned temp = MAXN;

	while(temp!=0) {
		*second++=*first++;
		temp--;
	}

	// print new array
	for(temp; temp<MAXN; temp++) printf("second[%d]\n", second[temp]);

}


Output:
1
2
3
4
5
6
7
8
9
10
second[5]
second[12]
second[23]
second[52]
second[4]
second[61]
second[23]
second[1]
second[9]
second[10]


Create a new paste based on this one


Comments: