Dynamic Memory Size

How can we know the size of Dynamically Created Array, as sizeof(array_name) will give us the pointer size?

You can’t.
The size of an array allocated with new[] is not stored in any way in which it can be accessed. Note that the return type of new [] is not an array - it is a pointer (pointing to the array’s first element).

So if you need to know a dynamic array’s length, you have to store it separately.

Can you please tell me in code how it is done?:pray:

it can’t be done

you have to store it separately before creating array

Okky Got it Saurabh. Thank you for explaining. Have a nice day.:blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.