I want to declare a double type array dynamically, so here is my code
void function(int length, ...)
{
    ...
    double *a = malloc(sizeof(double) * length);
    memset(a, 1, sizeof(double) * length);
    for (int i = 0; i < length; i++)
    {
        printf("%f", a[i]);
    }
    ...
}
When I pass a length of 2, the code does not print all 1s. It just prints the following:
7.7486e-304
7.7486e-304
So, what should I do to fix it?
 
     
     
     
     
     
    