I’m creating a Caesar Cipher in c++ and i can’t figure out how to increment a letter.
I need to increment the letter by 1 each time and return the next letter in the alphabet. Something like the following to add 1 to 'a' and return 'b'.
char letter[] = "a";
cout << letter[0] +1;
This snippet should get you started.
letteris acharand not an array ofchars nor a string.The
static_castensures the result of'a' + 1is treated as achar.Watch out when you get to
'z'(or'Z'!) and good luck!