Espacios de nombres
Variantes
Acciones

std::basic_ios::bad

De cppreference.com
< cpp‎ | io‎ | basic ios

 
 
Entrada / salida de la biblioteca
I / O manipuladores
C-estilo I / O
Buffers
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(obsoleto)
Arroyos
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstracciones
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
Cadena de 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
Matriz 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(obsoleto)
ostrstream(obsoleto)
strstream(obsoleto)
Tipos
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
Error interfaz categoría
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::basic_ios
Las funciones miembro
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.
basic_ios::basic_ios
basic_ios::~basic_ios
Funciones del Estado
Original:
State functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::good
basic_ios::eof
basic_ios::fail
basic_ios::bad
basic_ios::operator!
basic_ios::operator bool
basic_ios::rdstate
basic_ios::setstate
basic_ios::clear
Formato
Original:
Formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::copyfmt
basic_ios::fill
Varios
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::exceptions
basic_ios::imbue
basic_ios::rdbuf
basic_ios::tie
basic_ios::narrow
basic_ios::widen
Protegido funciones miembro
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::init
basic_ios::move
basic_ios::swap
basic_ios::set_rdbuf
 
bool bad() const;
Devoluciones true si no recuperable Error en la secuencia correspondiente. En concreto, los rendimientos true badbit si se encuentra en rdstate() .
Original:
Returns true if non-recoverable error has occurred on the associated stream. Specifically, returns true if badbit 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.
La biblioteca estándar establece badbit en las siguientes situaciones:
Original:
The standard library sets badbit in the following situations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • La inserción en el flujo de salida por put () o write () falla por alguna razón .
    Original:
    Insertion into the output stream by put() or write() fails for any reason.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • La inserción en el flujo de salida por << operador, std::put_money o std::put_time, no pudo completar porque el final de la secuencia de salida se alcanzó (La faceta función de formateado de salida como num_put::put() o money_put::put(), devuelve un iterador iter tal que iter.failed()==true)
    Original:
    Insertion into the output stream by << operador, std::put_money or std::put_time, could not complete because the end of the output stream was reached (The facet's formatting output function such as num_put::put() or money_put::put(), returns an iterator iter such that iter.failed()==true)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Stream se construye con un puntero nulo para rdbuf (), o rebote ofensivo () / unget () se llama en un arroyo con una rdbuf nula (), o un puntero nulo pasaron al operador << (* basic_streambuf)
    Original:
    Stream is constructed with a null pointer for rdbuf(), or putback()/unget() is called on a stream with a null rdbuf(), or a null pointer passed to operator<<(basic_streambuf*)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • rdbuf () -> sputbackc () o rdbuf () -> sungetc () devuelven rasgos :: eof () al rebote ofensivo () o unget ()
    Original:
    rdbuf()->sputbackc() or rdbuf()->sungetc() return traits::eof() to putback() or unget()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • rdbuf () -> pubsync () devuelve -1 para sincronizar (), a flush (), o al destructor de ostream :: centinela en una corriente unitbuf
    Original:
    rdbuf()->pubsync() returns -1 to sync(), to flush(), or to the destructor of ostream::sentry on a unitbuf stream
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Excepción se produce durante una operación de E / S de cualquier función miembro de la memoria de flujo asociado (por ejemplo sbumpc (), xsputn (), sgetc (), desbordamiento (), etc)
    Original:
    Exception is thrown during an I/O operation by any member function of the associated stream buffer (e.g. sbumpc(), xsputn(), sgetc(), overflow(), etc)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Excepción en iword () o pword () (por ejemplo, std :: bad_alloc)
    Original:
    Exception is thrown in iword() or pword() (e.g. std::bad_alloc)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

true si un error irrecuperable ha ocurrido, de lo contrario false .
Original:
true if a non-recoverable 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.

[editar] Ejemplo

[edit]
#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] Ver también

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