/*
* Function: itoa
* Objective: Convert int (i) to char* by adding 0x30 (decimal 48) to each digit and terminate the string.
* Synopsis: char* itoa(int i);
* Example(s): itoa(123456789);
* - returns "123456789"
* Notes: We sacrifice memory for speed by using the z variable
*/
char* itoa(int i)
{
if(i==0) return "0";
int w,x,y,z;
for(x=0;pow(10,x)<=i;x++) ;
char* string=malloc((sizeof(char)*x));
y=x-1;
for(x-=1;x>=0;x--)
{
z=pow(10,x);
if(x<0) break;
w=(i/z);
i=i-(z*w);
string[y-x]=(char)(w+'\x30');
}
return string;
}