Fixed bug in input of Caesar cipher while running

This commit is contained in:
2018-05-13 22:14:59 -04:00
parent 5043e4d3c3
commit ac94c663b4

View File

@@ -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);
}