source: doc/papers/llheap/examples/Fib.c @ 7bef8cf

ADTast-experimental
Last change on this file since 7bef8cf was 7bef8cf, checked in by Peter A. Buhr <pabuhr@…>, 19 months ago

start paper on llheap

  • Property mode set to 100644
File size: 400 bytes
RevLine 
[7bef8cf]1#include <stdio.h>
2
3typedef struct {
4        int fn1, fn;
5} Fib;
6
7#define FibCtor { 1, 0 }
8
9int fib( Fib * f ) {
10        int fn = f->fn; f->fn = f->fn1;
11                f->fn1 = f->fn + fn;
12        return fn;
13}
14int main() {
15        Fib f1 = FibCtor, f2 = FibCtor;
16        for ( int i = 0; i < 10; i += 1 ) {
17                printf( "%d %d\n", fib( &f1 ), fib( &f2 ) );
18        }
19}
20
21// Local Variables: //
22// tab-width: 4 //
23// compile-command: "gcc Fib.c" //
24// End: //
Note: See TracBrowser for help on using the repository browser.