You can use sprintf, which will add the number to character array. It even takes care of negative integers.
format: sprintf(target_string, format_string, parameter list)
sprintf(str, "The value of n is: %d", n);
Output: str gets the value "The value of n is: 2"
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.