有关缓冲区的事情
不是很明白有关输入输出缓冲区的原理,麻烦大佬讲讲
https://
去看看吧
程序代码:#include <iostream>
using namespace std;
int main() {
string password, temp;
int n, cnt = 0;
cin >> password >> n;
getchar(); //老哥,请问为啥要用getchar()呢
while(1) {
getline(cin, temp);
if (temp == "#") break;
cnt++;
if (cnt <= n && temp == password) {
cout << "Welcome in";
break;
} else if (cnt <= n && temp != password) {
cout << "Wrong password: " << temp << endl;
if (cnt == n) {
cout << "Account locked";
break;
}
}
}
return 0;
}