double * p =(double *)malloc(sizeof(double)* a . length)
If you define an array of type int, such as int a [10];
His length is simpler, n = sizeof(a)/sizeof(int).
Assuming that the array is of int type, first apply for 10 elements;
int * a =(int *)malloc(sizeof(int)* 10);
If there is another element, then you can.
a=(int *)realloc(a, 1 1 * sizeof(int));
Find the number of elements int i, n =1;
for(I = 0; (a+i)! = NULLi++)
{
}
n = I+ 1; //n is the number of elements.