i am trying to write a simple caesar cipher.
reading in a text file and using an offset I can decode the file, but handling capitol letters are not working.. here is the code for decryption part
as you can see below its not handling capitol letters good.Code:while (inputFile2) { inputFile2.get(ch); if (ch == '@' || ch == '%') { outfile << ch; } else if (islower(ch)) { ch = ch - offset; if ( ch < 'a' ) // 'A' for capitals. { ch = ch + 26; } outfile << ch; } else if (ch >= 'A' && ch <= 'Z') { ch = ch - offset; outfile << ch; } else if (ch == '#') { cout << endl << endl; } else if (ch == ' ' || ch == '\t' || ch == '\n') { outfile << ch; } else if (ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5' || ch == '6' || ch == '7' || ch == '8' || ch == '9') { outfile << ch; } }
output:
Code::he Declaration of Independence of the :hirteen Colonies In C5NG8E99 July 4 1776 :he unanimous Declaration of the thirteen united 9tates of America