std::ios_base::sync_with_stdio
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
static bool sync_with_stdio( bool sync = true ); |
||
Sets whether the standard std::cin, std::cout, std::cerr, std::clog, std::wcin, std::wcout, std::wcerr and std::wclog C++ streams are synchronized to the standard stdin, stdout, stderr and stdlog C streams after each input/output operation.
For a standard stream str
, synchronized with the C stream f
, the following pairs of functions have identical effect:
If the synchronization is turned off, the C++ standard streams are allowed to buffer their I/O independently, which may be considerably faster in some cases.
By default, all eight standard C++ streams are synchronized with their respective C streams.
It is implementation-defined if this function has any effect if called after some I/O occurred on the standard stream.
目录 |
[编辑] 参数
sync | - | the new synchronization setting |
[编辑] 返回值
synchronization state before the call to the function
[编辑] 为例
#include <iostream> #include <cstdio> int main() { std::cout.sync_with_stdio(false); std::cout << "a\n"; std::printf("b\n"); std::cout << "c\n"; }
Output:
b a c
[编辑] 另请参阅
写入标准C的输出流stdout
(全局对象)的 Original: writes to the standard C output stream stdout (全局对象) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
写入标准的C错误流stderr,unbuffered
(全局对象) Original: writes to the standard C error stream stderr, unbuffered (全局对象) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
写入标准的C错误流stderr
(全局对象) Original: writes to the standard C error stream stderr (全局对象) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |