Hi!
Can somebody tell me how to cast an int as a char so that 6 give '6' instead of '\x6'
I cannot use any labrary other then cstdio
Thank
The trick is to add '0'.
1 2
|
int num = 6;
char ch = num + '0'; // ch = '6'
|
Obviously this only works for single digits.
Last edited on