Fixed bug that would give invalid results with large offset

This commit is contained in:
2018-05-14 21:49:32 -04:00
parent d141ec61c8
commit 0ff6ad9ce7

View File

@@ -78,7 +78,7 @@ std::string Caesar::getOutputString() const{
* @return The encoded message (outputString)
*/
std::string Caesar::encode(){
char temp; //A temperary holder for the current working character
unsigned char temp; //A temperary holder for the current working character
for(unsigned int cnt = 0;cnt < inputString.size();++cnt){
temp = inputString.at(cnt);
//If it is a upper case letter shift it and wrap if necessary
@@ -130,7 +130,7 @@ std::string Caesar::encode(int shiftAmount, std::string input){
* @return The decoded message (outputString)
*/
std::string Caesar::decode(){
char temp;
unsigned char temp;
for(unsigned int cnt = 0;cnt < inputString.size();++cnt){
temp = inputString.at(cnt);
//If it is an upper case letter shift it and wrap if necessary