The Wayback Machine - https://web.archive.org/web/20180523181104/http://it.cppreference.com:80/w/cpp/io/ios_base/sync_with_stdio

std::ios_base::sync_with_stdio

Da cppreference.com.
< cpp‎ | io‎ | ios base

 
 
Ingresso / libreria di output
I / O manipolatori
C-style I / O
Buffer
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(deprecato)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Astrazioni
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
File I / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
String I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Array I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(deprecato)
ostrstream(deprecato)
strstream(deprecato)
Tipi
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Errore categoria interfaccia
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
std::ios_base
Membri funzioni
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::ios_base
ios_base::~ios_base
Formattazione
Original:
Formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::flags
ios_base::setf
ios_base::unsetf
ios_base::precision
ios_base::width
Versioni locali
Original:
Locales
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::imbue
ios_base::getloc
Interno di matrice estensibile
Original:
Internal extensible array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::xalloc
ios_base::iword
ios_base::pword
Varie
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::register_callback
ios_base::sync_with_stdio
Membri classi
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::failure
ios_base::Init
Membri tipi
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base::openmode
ios_base::fmtflags
ios_base::iostate
ios_base::seekdir
ios_base::event
ios_base::event_callback
 
staticbool 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:

1)std::fputc(f, c) and str.rdbuf()->sputc(c)
2)std::fgetc(f) and str.rdbuf()->sbumpc(c)
3)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.

Indice

[modifica]Parametri

sync - the new synchronization setting

[modifica]Valore di ritorno

synchronization state before the call to the function

[modifica]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

[modifica]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.
[edit]
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.
[edit]
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.
[edit]
close