【发布时间】:2020-07-03 18:06:28
【问题描述】:
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << "Print two numbers: ";
int x, y;
cin >> x >> y;
cout << x << y;
return 0;
}
Input : 23 24
Output : Print two numbers: 2324
在控制台、标准输入上打印“打印两个数字:”行之前的此处 正在等待 x 和 y,然后在控制台上将整个输出打印为 上面给出的。
从上述代码中删除同步行后:
#include <iostream>
using namespace std;
int main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
cout << "Print two numbers: ";
int x, y;
cin >> x >> y;
cout << x << y;
return 0;
}
这里首先是在控制台上打印“Print two numbers:”行 标准输入流正在等待 x 和 y。
我无法理解这种行为。
【问题讨论】:
-
此行为与与 stdio 同步无关。您更改了代码中的两行。
-
感谢@ThomasSablik,链接帮助。
标签: c++ io stl legacy-code