Skip to content

Instantly share code, notes, and snippets.

@felixge
Forked from tj/duff.c
Created April 14, 2012 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixge/2382696 to your computer and use it in GitHub Desktop.
Save felixge/2382696 to your computer and use it in GitHub Desktop.
duff's device
#include <stdio.h>
int
odd() {
static int i = -1;
return i += 2;
}
int
main(void) {
for (int i = 0; i < 10; ++i) printf("%d\n", odd());
}
1
3
5
7
9
11
13
15
17
19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment