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 t
You can use 'a'+((letter - 'a'+n)%26); assuming after 'z' you need 'a' i.e. 'z'+1='a'
#include using namespace std; int main() { char letter='z'; cout<<(char)('a' + ((letter - 'a' + 1) % 26)); return 0; }
See this https://stackoverflow.com/a/6171969/8511215