You have to think in ASCII codes. The ASCII code of A is 65. So what *c - 'A' does is to substract 65 from the character *c. This effectively gives the index of *c into the alphabet. /6 and %7 are to calculate row and columns and those values depend on the number of columns there are in your image.