fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string inttoa (int n) {
  6. string str = "";
  7. while (n) {
  8. string temp(1, n%10 + '0');
  9. str = temp + str;
  10. n -= n%10;
  11. n /= 10;
  12. }
  13. return str;
  14. }
  15.  
  16. int main() {
  17. cout << inttoa(123456) << "\n";
  18. return 0;
  19. }
Success #stdin #stdout 0s 3428KB
stdin
123456
stdout
123456