-florian66-

itoa

Jan 2nd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. char *itoa(int n, unsigned char* str, int base)
  2. {
  3.     int i=1, j=0, x;
  4.     if(n<0) str[j++] = '-', n = -n;
  5.     for(x=n;x;x/=base) j++;
  6.     for(x=n;x;x/=base) str[j-i++] = x%base + '0' + 39*(x%base>9);
  7.     str[j] = 0;
  8.     return str;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment