我正在使用以下代码:
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
string lineInput = " ";
while(lineInput.length()>0) {
cin >> lineInput;
cout << lineInput;
}
return 0;
}
使用以下命令:
echo "Hello" | test.exe
这将导致无限循环打印“Hello”。如何修改使其只打印一次“Hello”?