How to get the length of an array from a pointer?
You can't. And the moral is, don't use pointers and arrays, use vectors. You can always get the size of a vector.
You can't, I'm afraid. You need to pass the length of the array to anyone who needs it. Or you can use a std::array
or std::vector
or similar, which keep track of the length themselves.