Convert value received as int to char type in C

-1

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.

    
asked by anonymous 08.12.2017 / 20:40

1 answer

1

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

    
08.12.2017 / 20:58