Skip to content

Instantly share code, notes, and snippets.

@cceckman
Created February 27, 2014 06:32
Show Gist options
  • Select an option

  • Save cceckman/9245426 to your computer and use it in GitHub Desktop.

Select an option

Save cceckman/9245426 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int i = 0; // Static values are initialized to 0 according to C spec, this just makes it explicit
int foo(){
i = i + 1;
return i;
}
int main(){
int x;
for(x = 0; x < 10; x++){
int z = foo();
printf("I have called foo %d times\n", z);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment