>>647
int size = snprintf(NULL, 0, "%d", i);
char* buf = malloc(size+1);
sprintf(buf, "%d", i);
free(buf);