众所周知一个整型变量若使用输入cin进行输入,缓存区会锁住,那么我编译了如下代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
char ch;
while(1){
if(!(cin>>a)){
cin.clear();
cin>>ch;
cout<<ch<<endl;
}
}
}
其中输入+或-两次才会输出一次,如:
输入:+ +
输出:+
但是其他字符都是可以正常输出的,求助(
P.S.编译系统dev-cpp