Passing by reference in C

后端 未结 17 2215
梦如初夏
梦如初夏 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:36

    You're not passing an int by reference, you're passing a pointer-to-an-int by value. Different syntax, same meaning.

提交回复
热议问题