1 #include<std_lib_facilities.h>
2 int main()
3 {
4 int n;
5 cin>>n;
6 /*if (cin.fail())
7 cin.clear();*/
8 if(!cin)
9 cout<<"asf";
10 system("pause");
11 }
12
clear()will chang the condition of stream to good().This part of date's input and output are as follows:
input:as//not int
output:asd//cin is fail
1 #include<std_lib_facilities.h>
2 int main()
3 {
4 int n;
5 cin>>n;
6 if (cin.fail())
7 cin.clear();
8 if(!cin)
9 cout<<"asf";
10 system("pause");
11 }
12
when we uncomment the region and do not chang the input,there won't be any output.