c++:如果a要求输入一个数,我在输入时随意输入了一个字母之类的,怎样让程序输出指定的错误提示

日期:2018-05-10 14:42:06 人气:1

c++:如果a要求输入一个数,我在输入时随意输入了一个字母之类的,怎样让程序输出指定的错误提示

c++ cin 返回为假 就是输入错。 返回真,输入正确。 #include using namespace std; #include int main() { int x=0; Loop: cout << endl << "Enter an integer" << endl; if (cin >> x){ cout << "The value is " &
    A+
热门评论