Namespaces
Variants
Views
Actions

std::basic_ios::exceptions

From cppreference.com
< cpp‎ | io‎ | basic ios
Revision as of 18:49, 31 May 2013 by P12bot (Talk | contribs)

std::ios_base::iostate exceptions() const;
void exceptions(std::ios_base::iostate except);

Parameters

except - exception mask

Example

#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
    }
}