CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Static Local Variable Persists

C code walkthrough · Question 42
hardFunctions

Code

Read carefully. What does this print?
1#include <stdio.h>
2int next() {
3 static int count = 0;
4 count++;
5 return count;
6}
7int main() {
8 int a = next();
9 int b = next();
10 int c = next();
11 printf("%d %d %d", a, b, c);
12 return 0;
13}

Your answer