std::basic_istream::sync
Aus cppreference.com
[] |
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. |
<metanoindex/>
<tbody> </tbody> int sync(); |
||
Synchronisiert die Eingabepuffer mit der zugehrigen Datenquelle .
Original:
Synchronizes the input buffer with the associated data source.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Verhlt sich wie
UnformattedInputFunction, auer dass gcount() wird nicht beeinflusst. Nach dem Bau und Prfung der Schildwache ObjektOriginal:
Behaves as
UnformattedInputFunction, except that gcount() is not affected. After constructing and checking the sentry object,The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
wenn rdbuf() ein NULL-Zeiger ist, kehrt
-1Original:
if rdbuf() is a null pointer, returns
-1The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ansonsten ruft
rdbuf()->pubsync(). Wenn diese Funktion gibt -1, ruft setstate(badbit) und kehrt -1. Ansonsten kehrt 0 .Original:
Otherwise, calls
rdbuf()->pubsync(). If that function returns -1, calls setstate(badbit) and returns -1. Otherwise, returns 0.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Rckgabewert
0 bei Erfolg -1 bei Ausfall oder wenn der Strom nicht untersttzt diesen Vorgang (ungepuffert) .Original:
0 on success, -1 on failure or if the stream does not support this operation (is unbuffered).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Notes
Wie bei
readsome(), ist es durch die Implementierung definiert, ob diese Funktion nichts mit Bibliothek bereitgestellten Streams tut. Die Absicht ist in der Regel fr den nchsten Lesevorgang abholen alle nderungen, die mit dem zugehrigen Eingabesequenz vorgenommen wurden, nachdem der Stream-Puffer letzten fllte seine erhalten Gegend. Um das zu erreichen, synchronisieren () kann entleeren get-Bereich, oder es kann nachzufllen, oder es kann nichts tun. Eine bemerkenswerte Ausnahme ist Visual Studio, wo diese Operation verwirft das unbearbeitete Eingangssignal, wenn sie mit einem Standard-Input-Stream genannt .Original:
As with
readsome(), it is implementation-defined whether this function does anything with library-supplied streams. The intent is typically for the next read operation to pick up any changes that may have been made to the associated input sequence after the stream buffer last filled its get area. To achieve that, sync() may empty the get area, or it may refill it, or it may do nothing. A notable exception is Visual Studio, where this operation discards the unprocessed input when called with a standard input stream.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
Veranschaulicht die Verwendung von Input-Stream sync () mit Datei-Eingabe, wie auf einigen Plattformen nicht implementiert .
Original:
Demonstrates the use of input stream sync() with file input, as implemented on some platforms.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream>
#include <fstream>
void file_abc()
{
std::ofstream f("test.txt");
f << "abc\n";
}
void file_123()
{
std::ofstream f("test.txt");
f << "123\n";
}
int main()
{
file_abc(); // file now contains "abc"
std::ifstream f("test.txt");
std::cout << "Reading from the file\n";
char c;
f >> c; std::cout << c;
file_123(); // file now contains "123"
f >> c; std::cout << c;
f >> c; std::cout << c << '\n';
f.close();
file_abc(); // file now contains "abc"
f.open("test.txt");
std::cout << "Reading from the file, with sync()\n";
f >> c; std::cout << c;
file_123(); // file now contains "123"
f.sync();
f >> c; std::cout << c;
f >> c; std::cout << c << '\n';
}
Possible output:
Reading from the file
abc
Reading from the file, with sync()
a23
Siehe auch
[virtuell] |
synchronisiert die Puffer mit der zugehrigen Zeichenfolge Original: synchronizes the buffers with the associated character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtuellen geschtzten Member-Funktion of std::basic_streambuf)
|
synchronisiert mit dem zugrunde liegenden Speicher Original: synchronizes with the underlying storage device The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (ffentliche Elementfunktion of std::basic_ostream)
| |