c++ - Converting lower & upper case ASCII characters -
i'm making program converts ascii characters 'a' through 'z' , 'a' through 'z'. (only letters). example, a+1 = b
a+2 = c
b+1 = c
a+1 = b
so thing i'm not sure how mapping around. how can make when checklower/checkupper true, map around lower case letter (example, of z+2 = b).
the simplest way use %
modulus operator:
int letter_add = ((input.at(i) - 'a' + cmd_int) % 26) + 'a';
you'll need symmetrical line capital letters (or make 'a'
variable too).
Comments
Post a Comment