Any better alternatives for getting the digits of a number? (C++)
<p>I know that you can get the digits of a number using modulus and division. The following is how I've done it in the past: (Psuedocode so as to make students reading this do <em>some</em> work for their homework assignment):</p>

<pre><code>int pointer getDigits(int number) 
    initialize int pointer to array of some size
    initialize int i to zero
    while number is greater than zero
       store result of number mod 10 in array at index i
       divide number by 10 and store result in number
       increment i
    return int pointer
</code></pre>

<p>Anyway, I was wondering if there is a better, more efficient way to accomplish this task? If not, is there <em>any</em> alternative methods for this task, avoiding the use of strings? C-style or otherwise?</p>

<p>Thanks. I ask because I'm going to be wanting to do this in a personal project of mine, and I would like to do it as efficiently as possible. </p>

<p>Any help and/or insight is greatly appreciated. </p>
