There is a well known pattern of figuring out array length:
int arr[10]; size_t len = sizeof(arr) / sizeof(arr[0]); assert(len == 10);
T
As an expression (not a declaration), ptr[0] is identical to *ptr.
ptr[0]
*ptr
As long as the type of ptr is known and it is not pointing to void, sizeof is guaranteed to work on sizeof(*ptr) as well as sizeof(ptr[0]).
ptr
sizeof
sizeof(*ptr)
sizeof(ptr[0])