notes/snippet/cpp/test_static.c

20 lines
334 B
C

#include <stdio.h>
void test () {
static int num = 0;
num++;
printf("Function test has been called %d times\n", num);
}
void test2() {
static int num = 0;
num++;
printf("Function test2 has been called %d times\n", num);
}
int main(int argc, char **argv) {
test();
test();
test2();
test2();
}