0
Why is the size of the dynamic array b not the same as the array a, even though both have 17 elements ?
7 Respostas
+ 2
Kuldeep Singh because every pointer is 8 bit large so sizeof(b) = 8. But sizeof(b[0]) = 4, because it expects an integer at the pointers [0] position which has 4 bytes. And dividing the value with arrSize -> 2
+ 3
because b is not really a array it just stores the address of the first int
+ 3
thank you, Aaron Erhardt and Timon Paßlick
+ 2
b is not an array, it's a pointer. You divide the pointer size by what it points to.
+ 1
If it was a 32 bit architecture, you'd get the expected 1.
0
Aaron Erhardt but why is it printing 2 instead of 1 ? thx
0
Timon Paßlick or using a long long datatype which is 8 bytes large