c++ - Why does adding a '0' to an int digit allow conversion to a char? -


i've seen examples of on place:

int = 2; char c = + '0'; string s; s += char(i + '0'); 

however, have not yet seen explanation why adding 0 allows conversion.

if @ ascii table, asciitable, you'll see digits start @ 48 (being '0') , go 57 (for '9'). in order character code digit, can add digit character code of '0'.


Comments

Popular posts from this blog

java - How to print docx and pdf? -

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -

java - IntelliJ to move a class along with conflicted classes to a new package? -