An additional option you could do is to avoid using an array altogether by accessing the digits of the number directly:
unsigned int getDigit(unsigned int number, unsigned int index) {
// See http://stackoverflow.com/questions/4410629/finding-a-specific-digit-of-a-number
}
unsigned int setDigit(unsigned int number, unsigned int index, unsigned int newVal) {
// intPower is from the question linked to above.
return number - get(number, index)*intPower(10, index) + newVal*intPower(10, index);
}
unsigned int size(unsigned int number) {
// See http://stackoverflow.com/questions/1306727/way-to-get-number-of-digits-in-an-int
}
unsigned int push_back(unsigned int number, unsigned int newDigit) {
// Assuming no overflow
return 10*number + newDigit;
}
unsigned int pop(unsigned int number) {
// Assume number != 0
return number / 10;
}
This lets you treat your number as an array without actually initializing the array. You can even turn this into a class and use operator overloading to get actual array semantics.