Created
March 29, 2010 02:18
-
-
Save zed/347279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdio.h> | |
enum { N = 10 }; | |
static void inc(int* static_out, int* out){ | |
static int static_var = 0; | |
int var = 0; | |
++static_var; | |
++var; | |
printf("static_var=%d, var=%d\n", static_var, var); | |
*static_out = static_var; | |
*out = var; | |
} | |
int main(void) { | |
int i = 0; | |
int ret = -1; | |
int static_ret = -1; | |
for ( ; i < N; ++i) | |
inc(&static_ret, &ret); | |
assert(ret == 1); | |
assert(static_ret == N); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment