名前空間
変種
操作

cpp/io/basic ios/exceptions

提供: cppreference.com
< cpp‎ | io‎ | basic ios
std::ios_base::iostate exceptions() const;
void exceptions(std::ios_base::iostate except);

[編集] パラメータ

except -
例外マスク
Original:
exception mask
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <fstream>
 
int main() {
    int ivalue;
    try {
        std::ifstream in("in.txt");
        in.exceptions(std::ifstream::failbit);
        in >> ivalue;
    } catch (std::ios_base::failure &fail) {
        // handle exception here
    }
}