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

html - jquery - p element wont show after I hid it -

python - BeautifulSoup: How to get the nearest tag -

php - Return Last Insert ID with PDO -