Skip to content

Instantly share code, notes, and snippets.

@shivabhusal
Created May 12, 2017 03:33
Show Gist options
  • Select an option

  • Save shivabhusal/c82bee98b4432e5390df4db928a299f6 to your computer and use it in GitHub Desktop.

Select an option

Save shivabhusal/c82bee98b4432e5390df4db928a299f6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include "../cspec/cspec.c"
int * some_function(){
static int fun_call_counter = 0;
fun_call_counter++;
return &fun_call_counter;
}
void main(){
// `fun_call_counter` is not accessible here yet. And it does not make sense to even think about it
// because you cannot use that var `fun_call_counter` by name.
printf("the function is called %d times\n", *(some_function()));
printf("the function is called %d times\n", *(some_function()));
printf("the function is called %d times\n", *(some_function()));
printf("the function is called %d times\n", *(some_function()));
printf("the function is called %d times\n", *(some_function()));
printf("the function is called %d times\n", *(some_function()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment