请教一下各位大佬一个比较基本的问题qwq
问题1:
在打了
ios::sync_with_stdio(false);
的情况下,
cin.tie(0);
还有必要吗?能进一步加快速度吗qwq?
问题2、3:
以下代码:
cin.tie(0);
ios::sync_with_stdio(false);
cout << "hi";
cout << flush;
string s;
cin >> s;
会正常先输出 hi ,然后等待读入。
如果注释掉了
cout << flush;
代码好像就会留在缓存区,只有当
cin >> s
之后才会输出 hi。
然后,无论是只注释掉
cin.tie(0);
或者是
ios::sync_with_stdio(false);
都能在不进行
cout << flush;
的前提下先输出 hi。这是什么原理qwq?
不解绑的话是每次 cin 都会刷新缓存区吗?那为什么解绑但是不关闭同步流也会先输出 hi 呢?