]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - tests/tmp_tests/Frontend/struct_and_ptr_and_fact.c
Imported Upstream version 0.2
[pkg-cerco/acc.git] / tests / tmp_tests / Frontend / struct_and_ptr_and_fact.c
1
2 typedef struct foo {
3   int dummy;
4   int x;
5 } foo;
6
7 foo *p;
8 foo save;
9
10 int fact1 (int x) {
11   if (x <= 1) return 1;
12   return (x * fact1(x-1));
13 }
14
15 int fact2 (int x) {
16   int i, res = 1;
17
18   for (i = 1 ; i <= x ; i++)
19     res *= i;
20
21   return res;
22 }
23
24 int main () {
25   foo x, y;
26   foo* q[3];
27
28   x.x = 5;
29
30   q[1] = &x;
31   p = &x;
32   save = x;
33   x.x = fact1(save.x);
34   y.x = fact2(save.x);
35
36   print_sint((*(q[1])).x == y.x);
37   newline();
38
39   return 0;
40 }