From ac94c663b42130d551852c2e29d382b14b72bc2d Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Sun, 13 May 2018 22:14:59 -0400 Subject: [PATCH] Fixed bug in input of Caesar cipher while running --- helperFunctions.hpp | 7 +++++++ 1 file changed, 7 insertions(+) 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); }