Sadly, int is more difficult. I've done it but it involves muchos division. I'll get you started though:
1 2 3 4 5 6 7 8
int chiffre=12345;
string nombre;
int count=chiffre;
while (count>0)
{
//you'll have to use division to get the "ten thousands" and so on...
//don't forget to divide the number by 10 every time
}
I don't want to give away the answer since I found it fun to figure out.
Hello, nguyentrang.
First of all , you must include the sstream header : #include <sstream>
Declare a string : std::string s;
Than, declare an object of type stringstream : std::stringstream out;
Copy the content of d into out : out << d;
Finally, copy the content of out into s : s = out.str();
You now have in s the conversion of the integer d to a string.