0
if(std::cin){
decision = std::cin.get();
if(std::cin.eof())
throw CustomException("Error occurred while reading input\n");
}else{
throw CustomException("Error occurred while reading input\n");
}
清洗残留输入流上的
std::cin.ignore(COL_WIDTH, '\n'); // skip bad input
COL_WIDTH
读取从控制台输入是80作为通过Why is the default terminal width 80 characters?确定。我应该假设一个80个字符的控制台宽度,或者是一个更适合于cin.ignore
的更大数字?