]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - tests/tmp_tests/Frontend/array_copy.c
Imported Upstream version 0.2
[pkg-cerco/acc.git] / tests / tmp_tests / Frontend / array_copy.c
1
2 #define SIZE 5
3
4 int tab1[SIZE] = {10, -3, 25, 56, -32};
5
6 void copy (int dst[], int src[], int size) {
7   int i;
8
9   for (i = 0 ; i < size ; i++)
10     dst[i] = src[i];
11 }
12
13 void print_tab (int tab[], int size) {
14   int i;
15
16   for (i = 0 ; i < size ; i++) {
17     print_sint(tab[i]);
18     space();
19   }
20   newline();
21 }
22
23 int main () {
24   int tab2[SIZE];
25   int tab3[SIZE] = {0, 1, 2, 3, 4};
26
27   copy(tab2, tab1, SIZE);
28   copy(tab1, tab3, SIZE);
29
30   print_tab(tab1, SIZE);
31   print_tab(tab2, SIZE);
32   print_tab(tab3, SIZE);
33
34   return 0;
35 }