fork download
  1. #include <iostream>
  2.  
  3. int f()
  4. {
  5. static int n = 0;
  6.  
  7. return n++;
  8. }
  9.  
  10. int main()
  11. {
  12. for (unsigned i = 0; i < 20; ++i)
  13. std::cout << f() << '\n';
  14. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19