+ 2
How does this work?
Using templates, I added the sum of two characters 'A' and '1', the second as you see is number one. The result is 'r', same in code blocks. How does is work? https://code.sololearn.com/cIY28E1UOpzk/?ref=app
4 Réponses
+ 4
That code adds the ASCII values of the characters. The ASCII value of 'A' is 65 and the value of '1' is 49. The result is 114, the ASCII value of 'r'. That's why it prints 'r'
Take a look at the ASCII table:
http://www.asciitable.com
+ 4
Deroman thanks. One more favor please, show me how to return the ASCII values of the characters.
+ 4
char c = 'A';
int num = (int)c;
cout << num; //Prints 65
or just:
char c = 'A';
cout << (int)c; //Prints 65
+ 2
Deroman thanks once again.