1
0

loc_stat.c 402 B

123456789101112131415161718192021222324
  1. /* loc_stat.c -- using a local static variable */
  2. #include <stdio.h>
  3. void trystat(void);
  4. int main(void)
  5. {
  6. int count;
  7. for (count = 1; count <= 3; count++)
  8. {
  9. printf("Here comes iteration %d:\n", count);
  10. trystat();
  11. }
  12. return 0;
  13. }
  14. void trystat(void)
  15. {
  16. int fade = 1;
  17. static int stay = 1;
  18. printf("fade = %d and stay = %d\n", fade++, stay++);
  19. }