0
Char arithmetic
please who knows what goes on when you perform mathematical algorithms with an integer and a char
3 Respuestas
+ 4
Whenever you use type names like char, int/short/long etc., it's just a request to reserve a certain size of memory for your program. A char is one byte of memory and it can hold numerical values from 0 to 255 (unsigned) or -128 to 127 (signed). You don't necessarily have to use it for text characters like 'a', 'W' or '?', you can use it to store numerical values too (and do all sorts of calculations with them).
+ 2
A char is an integer. So the same thing that would happen if you did any mathematical operation with 2 integers.
See this table.
http://www.asciitable.com/
For example, if you do something like 'A' + 5 you'd get 70.
Because 'A' is the same as 65 and 65 + 5 = 70.
125521 / 'n' would be 1141, because 125521 / 110 = 1141.
+ 1
http://www.asciitable.com/
Each char has an integer representation. When your perform arithmetics on chars, you actually perform them on their integers.