Is there any way to get char by auto type deduction using decimal ASCII Code?

  • A+

For example 'a' has ASCII code 97 and we could use

char ch = 'a'; 


char ch = 97; 

With auto we could write

auto ch = 'a'; 

for the first case, but how to get char variable by numerical ascii code during deduction?

This doesn't work for me:

auto ch = '/97'; 


There's no decimal escape, but you can use hexadecimal: '/x61', or octal, '/141'.
If you really need decimal, you need to cast; char{97}.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: