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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -