[Solved] sizeof dynamic array is not correct [duplicate]


  • You don’t have an array; you have a pointer.

  • The size of the pointer is measured in bytes, not bits.

  • sizeof is evaluated at compile time and is constant for any given expression or type. It does not depend on the number of “filled” elements in an array (or pointer to some space that holds those elements, for that matter).

Your expression is equivalent to sizeof(int*), and pointers are 8 bytes in your environment.

6

solved sizeof dynamic array is not correct [duplicate]