ascii code

if c is a capital letter and c is from type char

what is the meaning of this expression?

(int)(c -'A')
You mean (int)('C' - 'A) and not (int)('c' - 'A') right?
no i mean like i wrote

c is a variable that contains an unknown capital letter
c is from type char
someone?
as in ascii code all capital letters are continuous ('A'==65, 'B'==66..., 'Z'==90), the meaning of (c -'A') is the index of the letter in c in the alphabet.
It gives the offset from A. So if c = A, the value is 0, 1 for B, 2 for C, all the way up to 25 or Z.
Topic archived. No new replies allowed.