Skip to content

Instantly share code, notes, and snippets.

@alex-pat
Created April 4, 2016 18:23
Show Gist options
  • Save alex-pat/724bcfbff27edd355364a7184bfae159 to your computer and use it in GitHub Desktop.
Save alex-pat/724bcfbff27edd355364a7184bfae159 to your computer and use it in GitHub Desktop.
itoa function realization
char* itoa( int number)
{
int count = 0;
int copy = number;
do {
count++;
} while ( copy /= 10 );
char* result = (char*) calloc( number+1, 1);
int i = count - 1;
for ( ; i >= 0; i-- )
{
result[i] = number%10 + '0';
number /= 10;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment