How sizeof(array) works at runtime?

前端 未结 6 1755
心在旅途
心在旅途 2020-11-28 10:45

I have read that sizeof operator in C is interpreted at compile time and since at compile time compiler knows the array size and its type,sizeof is abled to compute the numb

6条回答
  •  难免孤独
    2020-11-28 10:56

    From the C99 standard:

    6.5.3.4

    The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.

提交回复
热议问题