Guest User

Untitled

a guest
Jan 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. char* itoa(int x, char* str)
  2. {
  3. int rem;
  4. int i=0, j=0;
  5.  
  6. if (x < 0) {
  7. str[i++] = '-';
  8. x = -x;
  9. j++;
  10. }
  11.  
  12. do {
  13. rem = x % 10;
  14. x /= 10;
  15. str[i++] = (char)(rem + '0');
  16. } while (x > 0);
  17. str[i--] = 0;
  18.  
  19. while (j < i) {
  20. str[j] ^= str[i];
  21. str[i] ^= str[j];
  22. str[j] ^= str[i];
  23. j++; i--;
  24. }
  25.  
  26. return str;
  27. }
Add Comment
Please, Sign In to add comment