placing an unknown int size into a dyanmic array

Nov 3, 2010 at 12:15am
How do I take an integer of unknown size and store each integer (0-9) in a dynamic array. I know how to take a sing int (0-9) and turn it into a char, but if I have the integer 123, I need to store 1 in slot 0, 2 in slot 1, and 3 in slot 3 of the array/ I cannot use strings, only C++ type.
Nov 3, 2010 at 1:01am
oversize the array. (how big could be your number)
Nov 3, 2010 at 1:06am
the assignment states: there should never be more than 5 unused array slots left in the array at the end of any public operation. not to mention the number could be in the billions or trillions. So oversizeing is not an option
Nov 3, 2010 at 2:58am
closed account (D80DSL3A)
1
2
#include <cmath>
int Ndigits = 1 + (int)log10( (double)Number );
Nov 3, 2010 at 1:54pm
It sounds like you are being asked to write your own version of the std::vector class?
Topic archived. No new replies allowed.