Diferenças entre edições de "cpp/io/basic ios/operator!"
Da cppreference.com
m (r2.7.3) (Robô: A adicionar: de, en, es, fr, it, ja, ru, zh) |
m (Use {{lc}}. Update links. Various fixes.) |
||
Linha 2: | Linha 2: | ||
{{cpp/io/basic_ios/title | operator!}} | {{cpp/io/basic_ios/title | operator!}} | ||
{{cpp/io/basic_ios/navbar}} | {{cpp/io/basic_ios/navbar}} | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{| 1= |
bool operator!() const; | bool operator!() const; | ||
}} | }} | ||
− | {{ | + | {{end}} |
{{tr|Retorna {{c|true}} se ocorreu um erro no fluxo associado. Especificamente, os retornos {{c|true}} se {{tt|badbit}} ou {{tt|failbit}} é definido em {{c|rdstate()}}.|Returns {{c|true}} if an error has occurred on the associated stream. Specifically, returns {{c|true}} if {{tt|badbit}} or {{tt|failbit}} is set in {{c|rdstate()}}.}} | {{tr|Retorna {{c|true}} se ocorreu um erro no fluxo associado. Especificamente, os retornos {{c|true}} se {{tt|badbit}} ou {{tt|failbit}} é definido em {{c|rdstate()}}.|Returns {{c|true}} if an error has occurred on the associated stream. Specifically, returns {{c|true}} if {{tt|badbit}} or {{tt|failbit}} is set in {{c|rdstate()}}.}} |
Edição actual desde as 09h04min de 2 de julho de 2013
![]() |
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. |
bool operator!() const; |
||
Retorna true se ocorreu um erro no fluxo associado. Especificamente, os retornos true se
badbit
ou failbit
é definido em rdstate().Original:
Returns true if an error has occurred on the associated stream. Specifically, returns true if
badbit
or failbit
is set in rdstate().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.
Índice |
[editar] Parâmetros
(Nenhum)
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.
[editar] Valor de retorno
true se um erro ocorreu, false outra forma.
Original:
true if an error has occurred, false otherwise.
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.
[editar] Exemplo
#include <iostream> #include <fstream> #include <cstdlib> int main() { std::ifstream file("test.txt"); if(!file) // operator! is used here { std::cout << "File opening failed\n"; return EXIT_FAILURE; } // typical C++ I/O loop uses the return value of the I/O function // as the loop controlling condition, operator bool() is used here for(int n; file >> n; ) { std::cout << n << ' '; } std::cout << '\n'; if (file.bad()) std::cout << "I/O error while reading\n"; else if (file.eof()) std::cout << "End of file reached successfully\n"; else if (file.fail()) std::cout << "Non-integer data encountered\n"; }
[editar] Veja também
ios_base::iostate flags | basic_ios accessors | |||||||
eofbit | failbit | badbit | good() | fail() | bad() | eof() | operator bool() | operator!() |
false | false | false | true | false | false | false | true | false |
false | false | true | false | true | true | false | false | true |
false | true | false | false | true | false | false | false | true |
false | true | true | false | true | true | false | false | true |
true | false | false | false | false | false | true | true | false |
true | false | true | false | true | true | true | false | true |
true | true | false | false | true | false | true | false | true |
true | true | true | false | true | true | true | false | true |