c++ - Subtract a number from an ASCII char -


converting lower & upper case ascii characters

so, i'm trying in thread, except want go backwards ascii conversion (letters only) aka, if gave number 1.

b+1 =  b+1 = (capital becomes capital)  c+2 =  z+1 = y  a+1 = z 
int lower_add = ((letter - 'a' - input_int) % 26) +'a'; if ((lower_add -'a' - input_int) < 0)     lower_add = lower_add +26; 

this getting it, except there cases b+1 go other non-letter ascii char.

lower_add has input_int subtracted out, don't second time. change if to:

if (lower_add < 'a')     lower_add += 26; 

this still won't deal capital letters correctly, you'll need range test decide whether subtract 'a' or 'a'.


Comments

Popular posts from this blog

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

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

url rewriting - How to redirect a http POST with urlrewritefilter -