diff --git a/helperFunctions.hpp b/helperFunctions.hpp index 5582697..b44bbf9 100644 --- a/helperFunctions.hpp +++ b/helperFunctions.hpp @@ -147,7 +147,14 @@ std::string runCaesar(std::ifstream& infile, bool encode){ else{ std::cout << "Enter the cipher offset: "; std::cin >> offset; + if(std::cin.fail()){ + std::cin.ignore(10000, '\n'); + std::cin.clear(); + std::cout << "That is an invalid offset\nEnter the cipher offset: "; + std::cin >> offset; + } std::cout << "Enter the input string: "; + std::cin.ignore(10000, '\n'); std::getline(std::cin, inputString); }