fork(19) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void callMe(int j) {
  6.  
  7. static int i;
  8.  
  9. ++i;
  10. ++j;
  11. printf("Loop: %d\n", i);
  12.  
  13. printf("i memory location: %p\n", &i);
  14. printf("j memory location: %p\n", &j);
  15.  
  16. printf("\n");
  17.  
  18. if ( i < 10 )
  19. callMe(j);
  20.  
  21. printf("Returning from loop %d\n", j);
  22. }
  23.  
  24. int main() {
  25.  
  26. callMe(0);
  27. printf("Next\n");
  28. callMe(0);
  29.  
  30. return 0;
  31.  
  32. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Loop: 1
i memory location: 0x804a038
j memory location: 0xbfc9cd30

Loop: 2
i memory location: 0x804a038
j memory location: 0xbfc9cd20

Loop: 3
i memory location: 0x804a038
j memory location: 0xbfc9cd10

Loop: 4
i memory location: 0x804a038
j memory location: 0xbfc9cd00

Loop: 5
i memory location: 0x804a038
j memory location: 0xbfc9ccf0

Loop: 6
i memory location: 0x804a038
j memory location: 0xbfc9cce0

Loop: 7
i memory location: 0x804a038
j memory location: 0xbfc9ccd0

Loop: 8
i memory location: 0x804a038
j memory location: 0xbfc9ccc0

Loop: 9
i memory location: 0x804a038
j memory location: 0xbfc9ccb0

Loop: 10
i memory location: 0x804a038
j memory location: 0xbfc9cca0

Returning from loop 10
Returning from loop 9
Returning from loop 8
Returning from loop 7
Returning from loop 6
Returning from loop 5
Returning from loop 4
Returning from loop 3
Returning from loop 2
Returning from loop 1
Next
Loop: 11
i memory location: 0x804a038
j memory location: 0xbfc9cd30

Returning from loop 1