Pointer to function parameter vs function parameter?

后端 未结 3 1963
遇见更好的自我
遇见更好的自我 2021-02-20 10:50

I\'d like to understand what is the difference between the 2 declarations, f1 and f2, below: In f1 I declare the parameter to be a pointer

3条回答
  •  名媛妹妹
    2021-02-20 11:18

    They're equivalent. You're getting confused by the implicit pointer conversion that happens with arguments.

    Since you can't pass a function as an argument to a function (you can't do anything with functions in C other than call them or take their address), the compiler silently changes the argument into a pointer to a function.

    This is much the same as happens with arrays -- you can't pass arrays as function arguments either, so any time you declare a function argument as an array, it silently gets changed into a pointer.

提交回复
热议问题