This might be sufficient.
string convertInt(int number)
{
if (number == 0)
return "0";
string temp="";
string returnvalue="";
while (number>0)
{
temp+=number%10+'0';
number/=10;
}
for (int i=0;i<temp.length();i++)
returnvalue+=temp[temp.length()-i-1];
return returnvalue;
}
(I did not write this function, but found it by doing a quick Google search. The original post is here.)
This function works by dividing the number by 10. It takes the remainder of the division, which will always be between 0 and 9. It then "finds" the character representing that number by adding the integral value of the character 0 to it.
Next, it takes the quotient of that division, and performs the same operation again and again until the quotient is zero.
This results in a string that contains the characters representing the number, but in reverse order. The final loop reverses the string before returning it.
As chris points out in the comments below, the digits 0 through 9 are guaranteed to be in sequential order
N3485, §2.3 [lex.charset]/3: In both the source and execution basic
character sets, the value of each character after 0 in the above list
of decimal digits shall be one greater than the value of the previous.
(the above list is, quite intuitively, 0 1 2 3 4 5 6 7 8 9).
Here is good reading material about string manipulation: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)