Possible Duplicate:
how to rotate the given string to left or right in C?
So i am write code that encrypt a string. As known as Ceasar cipher.
But instead of constantly doing right rotation.
for Shift = 1, A=65, so i do 65+shift = 66, which is B. … C=>D.D=>E….
What if i want to do left rotation as well?
Now, A(65) => Z(90), B(66) =>A(65), C(67)=>B(65)…Y(89)=>X(88)
Is known that we can just do like original – shift, except for A(65).
so instead of creating a if(notA)… else(handle A).
Are there any elegant way to do so? In addition, if the shift is other number,there are more cases to consider…
Its there any other way to do so? like using mod or something??
Have a look-up table.
Similarly, you can have other lookup tables if you want a mix of small letters, numbers etc and change the logic accordingly.