All pastes #735162 Raw Edit

Ankur

public c v1 · immutable
·published 2007-10-13 11:41 UTC
rendered paste body
char * itoa(int n, char *buff, int radix)// convert a positive integer n to char *buff// for instant, this function work with radix <= 10;// a little change to run with radix > 10{      int q, r;      int i = 0;      char tmp[33];  // for radix = 2 and 32 bits computer      do{            q = int(n / radix);            r = n % radix;            n = q;            tmp[i++] = 48 + r;      }while(q > 0);      int j;      for(j = 0; j < i; j++){            buff[j] = tmp[i - j - 1];      }      buff[j] = NULL;      return buff;}