Okay, sorry. (I did say "kind of". ) To print "one two three" for 123, you need to start at the highest digit and count down to the lowest. The first thing you need to do is figure out how many digits the number has. This can be accomplished with this loop:
Code:
for(digits = 0; number /= 10; digits ++);
number = onumber;
or
Code:
digits = 0;
for(;;) {
number = number / 10; /* remove a digit */
if(!number) { /* no digits left */
break; /* end the loop */
}
}
number = onumber;
Then you need to somehow get the digitsth digit, and then the one less than that, etc. Sounds like another loop is required.
Code:
for(x = 0; x < digit; x ++) number /= 10;
number %= 10;
or
Code:
x = 0;
for(;;) {
if(x == digit) {
number = number % 10; /* remove digits higher than the current one */
break; /* end the loop */
}
number = number / 10; /* remove the lowest digit */
}
But wait . . . you want to process all the digits, not just one. Sounds like another loop.
Code:
for(which = digits-1; which >= 0; which --) {
/* process the whichth digit */
}
I don't see any other way for it; you need at least 3 loops.