fork download
  1. #include <stdio.h>
  2.  
  3. int a = 0;
  4.  
  5. /* func関数の定義 */
  6. void func(void)
  7. {
  8. int b = 0;
  9. static int c = 0;
  10.  
  11. printf("変数aは%d変数bは%d変数cは%dです。\n",a, b, c);
  12.  
  13. a++;
  14. b++;
  15. c++;
  16. }
  17.  
  18. /*main関数の定義 */
  19. int main(void)
  20. {
  21. int i;
  22.  
  23. for(i=0; i<5; i++)
  24. func();
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
変数aは0変数bは0変数cは0です。
変数aは1変数bは0変数cは1です。
変数aは2変数bは0変数cは2です。
変数aは3変数bは0変数cは3です。
変数aは4変数bは0変数cは4です。