answersLogoWhite

0


Best Answer

You can find the number of elements and free elements in a pointer array by iterating through the array and counting the number of elements that are null versus the number that are non-null. Of course, this technique's success depends on proper initialization of each element, i.e. when first created or when deleted, it must be set to null.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How you can find out the number of elements and free elements in a pointer array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you find the length of a single dimensional array in BlueJ?

array.length will return the number of elements in array.


What is the index number of the last element of an array with 9 elements?

(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).


How can you find the length of multi dimensional array according to data structure?

There is no way to determine the length of an array in C. All arrays implicitly convert to pointers and a pointer tells you nothing about the number of elements it refers to. The only way to keep track of the number of elements being referred to is to store the length of the allocation at the time the allocation was made. If you fail to store the length, then there is simply no way to calculate it. Note that the length of a fixed-length array is always known to the compiler but only within the scope of the declaration. If we pass a fixed-length array to a function, the array implicitly converts to a pointer and the length can no longer be determined. However, we can use a constant variable to keep track of a fixed-length array's size and pass both the array and its length as separate arguments to a function. For variable-length arrays we must use non-constant variables. A structure helps to encapsulate both pieces of information. For example, the following structure can be used to keep track of integer arrays: typedef struct int_array { int* ptr; // pointer to a variable-length array of type int unsigned size; // the number of elements allocated to the array }; We can also use structures such as this to keep track of how many elements are actually in use. This is useful as it allows us to push values into the array without having to continually re-allocate the array, which is an expensive operation.


Find index number of an given array?

For instance, you have array of type int with a name myArray, and you do not know size of the array. You can use following statement to get it:int arraySize = myArray/myArray[0];arraySize gives you number of elements in myArray.


Explain how an array of 5 x 46 can help you find the product of 5 x 46?

The number of elements in a 5 x 46 array = 5*46.


How do you find the average of rows and columns in a 2d array in java?

You add up all the array elements, then divide by the number of elements. You can use a nested for() loop in Java; inside the inner for() loop, you can both increase a counter (to count how many elements there are), and add to a "sum" variable.


Which take a string as input and find its length?

strlen is the C library function that accepts a pointer to a char array and returns an integer specifying the number of characters (in bytes) of the array. This function is usually not used any more, because it does not support multi-byte characters, such as UTF-8.


How do you find missing numbers in a array with elements below its size?

Please rephrase your question. An array usually has a fixed size and I don't recall ever having to "go below its size". This implies that the missing elements are not within the range of the array.


Writing in math explain how an array of 5 x 46 can help you find the product of 5 x 46?

The number of elements (cells) in a 5 x 46 array = 5*46.


Relation between array and pointer?

A pointer identifies the location of some data in memory, similarly to an envelope with a street address on it. An array is several values of the same type, stored next to each other in memory. A useful consequence is that all of an array's elements may be found by simply counting up from the address of the first element. Note that, when an array value is made available outside of its original scope, it decays to a pointer to its first element. So, for example, sizeof returns a different size for an array depending on which scope you call it in. In the array's original scope, it returns the number of elements in the array; in any other scope it returns the number of bytes used to store the pointer.


How can you get position of number from given some number by using array in c language?

Traverse the array from index 0 until you find the number. Return the index of that number.


Program to print all the even numbers of an array in visual basic?

find even number in array