Passing by reference in C

后端 未结 17 2410
梦如初夏
梦如初夏 2020-11-21 23:26

If C does not support passing a variable by reference, why does this work?

#include 

void f(int *j) {
  (*j)++;
}

int main() {
  int i = 20;         


        
17条回答
  •  野的像风
    2020-11-21 23:50

    Because you're passing the value of the pointer to the method and then dereferencing it to get the integer that is pointed to.

提交回复
热议问题