# Help with ArraySize 16

Hi,

I know this is quite basic, but I have a doubt on ArraySize function; does it return the size of the array or the number of non-null elements in the array?

For example:

double array[];

ArrayResize(array,100);

array=4;

array=4;

array=4;

int size=ArraySize[array];

In this case, will ArraySize function return a value of 3 (number of non-null elements), or a value of 100 (the actual size of the array)?

Many thanks! 1484

Why don't you try and see? Moderator
29965

toshiorusso86:

Hi,

I know this is quite basic, but I have a doubt on ArraySize function; does it return the size of the array or the number of non-null elements in the array?

For example:

double array[];

ArrayResize(array,100);

array=4;

array=4;

array=4;

int size=ArraySize[array];

In this case, will ArraySize function return a value of 3 (number of non-null elements), or a value of 100 (the actual size of the array)?

Many thanks!

A simple test will give you the answer. It returns the number of elements.

Be aware that with multi dimension arrays it will return the total elements for all dimensions. In this case if you want the number of elements in a dimension, you must use ArrayRange() 16

Will test it :) Many thanks for the help and additional info

So I assume it will return 100 in this case...do you know how I could get to the number of non-null elements in the array?

Thanks! 1484

Try to print an uninitialized element.
Elements that are not initialized get the value 0.
So you can't know which elements are not initialized, if 0 is a legitimate value in the array. 16

Amir Yacoby:
Try to print an uninitialized element.
Elements that are not initialized get the value 0.
So you can't know which elements are not initialized, if 0 is a legitimate value in the array.
I tested it and I get your point, I will try with a for loop then