Difference between passing array and array pointer into function in C

前端 未结 3 1212
予麋鹿
予麋鹿 2020-11-22 04:00

What is the difference between the two functions in C?

void f1(double a[]) {
   //...
}

void f2(double *a) {
   //...
}

If I were to call

3条回答
  •  猫巷女王i
    2020-11-22 04:24

    The difference is purely syntaxic. In C, when the array notation is used for a function parameter, it is automatically transformed into a pointer declaration.

提交回复
热议问题