I'd like to convert a int digit to a char (no to convert from ascii code). I'd like to convert it from int type to char type. (Example: from 5 to '5') Is it possible?
Asked
Active
Viewed 49 times
0
-
Unclear. Are you looking to *print* the digit? `cout`. Are you looking to cast the *type* of the variable? `static_cast
`. Something else? Please be a bit more specific. – DevSolar Nov 02 '20 at 13:40 -
I'd like to cast to a char – Moldytzu Nov 02 '20 at 13:40
-
Here's [a link](https://stackoverflow.com/questions/17984975/convert-int-to-char-in-java) with same question on stackoverflow. – slimpa Nov 02 '20 at 14:11
-
It crashes when it executes that line of code – Moldytzu Nov 02 '20 at 14:14
-
Are you looking for `int x = 5; char c = '0' + x; // c == '5'` ? – Igor Tandetnik Nov 02 '20 at 14:40
-
It delivers very intresting values: 5P≈^ – Moldytzu Nov 02 '20 at 16:05