source: doc/papers/concurrency/examples/Fib.c @ b797d978

ADTast-experimental
Last change on this file since b797d978 was 600d7be, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

example updates

  • Property mode set to 100644
File size: 400 bytes
Line 
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.