You should use static_cast(i)
to cast the integer i
to char
.
reinterpret_cast
should almost never be used, unless you want to cast one type into a fundamentally different type.
Also reinterpret_cast
is machine dependent so safely using it requires complete understanding of the types as well as how the compiler implements the cast.
For more information about C++ casting see:
- When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?
- http://www.cplusplus.com/doc/tutorial/typecasting/.