fork download
  1. #include <stdio.h>
  2.  
  3. /*
  4. 値渡しと参照渡し
  5. */
  6.  
  7. /* 値渡し */
  8. void func1(int a) {
  9. a = 789;
  10. }
  11.  
  12. /* 参照渡し */
  13. void func2(int a[]) {
  14. a[1] = 1000;
  15. }
  16.  
  17. int main(void) {
  18. int a = 123;
  19. int b[] = {1,2,3,4,5};
  20.  
  21. func1(a);
  22. printf("after call func1:%d\n", a);
  23.  
  24. func2(b);
  25. for(int i=0; i<5; i++)
  26. printf("%d ", b[i]);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
after call func1:123
1 1000 3 4 5