How Does sizeof(Array) work

后端 未结 5 964
我在风中等你
我在风中等你 2020-11-27 15:42

How does c find at run time the size of array? where is the information about array size or bounds of array stored ?

5条回答
  •  無奈伤痛
    2020-11-27 16:04

    sizeof() will only work for a fixed size array (which can be static, stack based or in a struct).

    If you apply it to an array created with malloc (or new in C++) you will always get the size of a pointer.

    And yes, this is based on compile time information.

提交回复
热议问题