cs161AWinter2024/cinfail.cpp

21 lines
335 B
C++

#include <iostream>
using namespace std;
int main(){
int num1;
int num2;
string rest;
cout << "Enter two numbers, separated by a space: ";
cin >> num1;
cin >> num2;
if(cin.fail()){
cout << "oh, it failed" << endl;
cin.clear();
cin >> rest;
cout << "The rest was: " << rest << endl;
}
return 0;
}