sizeof array clarification

后端 未结 6 2248
不知归路
不知归路 2020-12-06 18:34

I am studying for a final tomorrow in C, and have a question regarding the sizeof operator.

Let\'s say the size of an int is 32 bits and a

6条回答
  •  悲&欢浪女
    2020-12-06 18:58

    Because zip is an array and the compiler knows its size at compile-time. It just a case of using the same notation for two different things, something quite usual in C.

    int
    foo (int zap[])
    

    is completely equivalent to

    int
    foo (int *zap)
    

    The compiler doesn't have any idea how big zap could be (so it leaves the task of finding out to the programmer).

提交回复
热议问题