Can I use arrays as a function parameter in C99?

前端 未结 2 1789
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 03:45

The C99 standard says the following in 6.7.5.3/7:

A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to

2条回答
  •  遇见更好的自我
    2021-01-28 03:51

    Both your valid and invalid declarations are internally equivalent, i.e., the compiler converts the latter to the former.

    What your function sees is the pointer to the first element of the array.

    PS. The alternative would be to push the whole array on the stack, which would be grossly inefficient from both time and space viewpoints.

提交回复
热议问题