Was bedeutet rdstate () Rückgabewert?
istream& Read(istream &is)
{
std::string buf;
while (is >> buf)
{
cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl;
cout << is.rdstate() << endl;
cout << buf << endl;
}
cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl;
cout << is.rdstate() << endl;
is.clear();
cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl;
cout << is.rdstate() << endl;
return is;
}
Wenn ich normale Zeichen wie "test" eingebe, ist die Ausgabe1 2 4 0
.
Wenn ich STRG + Z (Windows) eingebe, ist die Ausgabe1 2 4 3
1 2 4 0
.
Frage: 1. Was machtrdstate()
Rückgabewert bedeutet? (Warum wird 3 ausgegeben, nicht 2? Nicht 1?)
is.eofbit
undis.failbit
change nachdem ich STRG + Z eingegeben habe? (Wie C ++ Primer 5th Editon sagt, das Erreichen des Dateiendes setzt sowohl eofbit als auch failbit)