I had to lookup what itoa is not being a C programmer. Which got me interested - how would you implement this?
My inital thought is to do something like (in pseudo code):
str = '';
while (i > 0 ) {
# least significant digit
r = i % 10;
# throw away the least significant digit
i = i / 10;
case
when r = 0 then
str = '0' << str
when r == 1 then
str = '1' << str
... etc
end
}
return str;
Would I pass with that? Is there a better way?