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