int numToConvert = *your number*; // calculate the length of the resulting string int ENOUGH = malloc(sizeof(char)*(int)log10(numToConvert)); char str[ENOUGH]; sprintf(str, "%d", 42); // str contains the number in string form