converts an integer into a string of digits: - C String

C examples for String:String Function

Description

converts an integer into a string of digits:

void itoa(int p, char str[])
{
  int j, sign;
  if((sign = p) < 0)
    p = -p;
  j = 0;
  do{
    str[j++] = p % 10 + '0';
  }while((p /= 10) > 0);
  if(sign < 0)
    str[j++] = '-';
  str[j] = '\0';
  reverse(str);
}

Related Tutorials