fork(2) download
  1. #include <stdio.h>
  2.  
  3. static int externa = 1;
  4.  
  5. static void teste() {
  6. int x = 0;
  7. static int estatica = 0;
  8. x++;
  9. estatica++;
  10. printf("x = %d, estatica = %d, externa = %d\n", x, estatica, externa);
  11. }
  12. int main() {
  13. printf("externa = %d\n", externa);
  14. for (int i = 0; i < 10; i++) {
  15. teste();
  16. }
  17. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
externa = 1
x = 1, estatica = 1, externa = 1
x = 1, estatica = 2, externa = 1
x = 1, estatica = 3, externa = 1
x = 1, estatica = 4, externa = 1
x = 1, estatica = 5, externa = 1
x = 1, estatica = 6, externa = 1
x = 1, estatica = 7, externa = 1
x = 1, estatica = 8, externa = 1
x = 1, estatica = 9, externa = 1
x = 1, estatica = 10, externa = 1