Comment convertir un int en char pour que la valeur numérique du int devienne un nombre écrit ? par ex:
pour que : int nombre = 18;
donne une fois convertit char chaine[]="18"
J'ai essayé : static_cast<char>(nombre), mais ça ne marche pas car ça ne fait que donnerle caractère ascii présent à la position 18.
#include <stdlib.h>
char *itoa(int value, char *string, int radix);
Description
Converts an integer to a string.
itoa converts value to a null-terminated string and stores the result in string. With itoa, value is an integer.
radix specifies the base to be used in converting value; it must be between 2 and 36, inclusive. If value is negative and radix is 10, the first character of string is the minus sign (-).
Note: The space allocated for string must be large enough to hold the returned string, including the terminating null character (\0). itoa can return up to 17 bytes.