I'm doing a college job where I have to convert a received value to char so I can write it in full for example. Help me create this function.
I'm doing a college job where I have to convert a received value to char so I can write it in full for example. Help me create this function.
A character can only represent a number from 0 to 9.
If you want to convert a number greater than 9 to a string
see: Converting int to string
If you really wanted an integer like char
, you could do this as follows:
int main(int argc, char *argv[]) {
int inteiro = 1;
char caractere = inteiro+'0';
printf("%c",caractere);
return 0;
}
Seemoreexplanations: Converting int to char in C