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
的更大數字?