![]() |
In C++, dynamic memory allocation enables the users to manage the memory resources during the execution of the program and is very useful for arrays when the size of the array is not known at compile time or during any other times for flexibility. In this article, we will learn how to find the size of a dynamically allocated array in C++. Finding the Size of a Dynamically Allocated Array in C++Unfortunately, when we dynamically allocate an array using the Therefore, there is no direct way to find the size of a dynamically allocated array. To manage the size of a dynamically allocated array, we must keep track of the size separately. The below program demonstrates one method where we track the size of an array in a separate variable. C++ Program to Keep the Track of Dynamically Allocated ArrayC++
Output
0 1 2 3 4
|
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |