std::ios_base::sync_with_stdio
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody> 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:
std::fputc(f, c) and str.rdbuf()->sputc(c)std::fgetc(f) and str.rdbuf()->sbumpc(c)std::ungetc(c, f) and str.rdbuf()->sputbackc(c)
In practice, this means that the C++ and the C streams use the same buffer, and therefore, can be mixed freely. In addition, synchronized C++ streams are guaranteed to be thread-safe (individual characters output from multiple threads may interleave, but no data races occur)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.
Parametri
| sync | - | the new synchronization setting |
Valore di ritorno
synchronization state before the call to the function
Esempio
#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
Vedi anche
scrive nel flusso di output standard di stdout
(oggetto globale) C Original: writes to the standard C output stream stdout (oggetto globale) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
scrive nel flusso di errore standard di C stderr, unbuffered
(oggetto globale) Original: writes to the standard C error stream stderr, unbuffered (oggetto globale) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
scrive allo standard stderr
(oggetto globale) flusso di errore C Original: writes to the standard C error stream stderr (oggetto globale) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |