Suppose I want to define a structure representing length of the vector and its values as:
struct Vector{ double* x; int n; };
Now,
The first time around, you allocate memory for Vector, which means the variables x,n.
Vector
x
n
However x doesn't yet point to anything useful.
So that is why second allocation is needed as well.