Decimal to ASCII char

Is there any way to convert an int value to a char value that is corresponding to its ASCII value?
ex.
int a
a = 87
ASCII of a = 'W'

Thanks
You can simply cast it.

1
2
int a = 87;
char W = static_cast<char>(a);
You need not fo any conversion because int and char are integral types. It is only visual representation of a character provided by output functions for objects of type char.

So you can write simply

int a = 87;
char b = a;

or

std:;cout << ( char )a << std::endl;
or
std:;cout << static_cast<char>( a ) << std::endl;
or
std:;cout << b << std::endl;
Thanks for the help the "static_cast<char>" works!
There is
char itoa(int )
and
int atoi(char)
function also available.
Last edited on
Topic archived. No new replies allowed.