At the line int index = currentChar - 'a';
The currentChar
(what ever it is) will be subtracted by 'a' character which has the ASCII
value 97.
In this case you have two conditions:
First If
currentChar
is between a-z, the result ofindex
will always be>= 0
.Otherwise
currentChar
is not between a-z becauseindex
will be negative number, currentChar can't be betweenA-Z
because of thetolower()
function.
You can refeare to this link to know more about ASCII
values
Also you need to update the condition assert(index >= 0 && index < 26)
because { ,} ,| and ~ will make index >=0