First calculate no of digits
int count = 0;
int n = number;
while (n != 0)
{
n /= 10;
cout++;
}
Now intialize the array and assign the size:
if(count!=0){
int numberArray[count];
count = 0;
n = number;
while (n != 0){
numberArray[count] = n % 10;
n /= 10;
count++;
}
}