【发布时间】:2018-06-01 04:27:19
【问题描述】:
这是我的代码:
#include <iostream>
#include <vector>
using namespace std;
int main(){
int x=-1;
while(x != 0)
{
x = 0;
cout << "nuevo numero: ";
cin >> noskipws >> x;
cout << x << endl;;
}
}
输出是:
nuevo numero: 5 // I input that number
5
nuevo numero: // Here it doesn't wait for an input
0 // I don't know where this come from, guess it's the empty input
我知道这与noskipws 有关,但我不知道确切原因,也不知道如何解决。
问题: 为什么第二个cin >> noskipws 不等待输入?我该如何解决?
【问题讨论】: