#include #define ITOA(i)\ ({\ __typeof__(i) _i = (i), negative = _i < 0 ? 1 : 0;\ const char digits[] = "0123456789";\ char *str = malloc((size_t)log10(_i) + 2 + negative) + (int)log10(_i) + 1 + negative;\ *str-- = 0;\ for(; _i; _i /= 10) *str-- = digits[_i % 10];\ if(negative) *str-- = '-';\ ++str;\ })