I tried the following code in order to see how to get size of the data of a pointer:
#include
#include
#include
sizeof only knows the full size of the array if that's statically known at compile time. For a pointer, it will return the size of the memory address, i.e. 4 on 32-bit, 8 on 64-bit.
When you use pointers, it's up to you to know and keep track of the size of the data it points to. The language implementation won't do it for you like it would for arrays.