Hello, it is not entirely clear what it is .... if(errno==ERANGE) , if(state & ios::badbit) , if(state & ios::failbit)

 if(errno==ERANGE) { cout << "Error! Number out of range!\n"; //return 0; } if(!(isdigit(str[0])||(str[0] == '-')||(str[0] == '+'))) { cout << "Error! In file is no integer symbols!\n"; //return 0; } for(i=1;i<strlen(str);i++) if(!isdigit(str[i])) { cout << "Error! In file is no integer symbols!\n"; //return 0; } if(state & ios::failbit) { cout << "Formate error!\n"; //return 0; } if(state & ios::badbit) { cout << "Fatal error!\n"; //return 0; } 

Who can explain is available? What is compared with what? (Used with the #include <errno.h> library)

    1 answer 1

    In this case, you need to very well understand the bit operation &.
    Let the state number be given - and consist of N bits. Then this number can carry information about N errors, if the i-th bit in this number equals 1-an error has occurred, 0 - not.
    In this case, if state & (constant)! = 0 , then a corresponding error has occurred.
    ios :: badbit is a constant responsible for the error, just like the bad function
    ios :: failbit - like the fail function
    The errno variable is written to read variable. Error ERANGE - occurs if we read a value in a variable that does not fit into the variable.
    Here is a list of reading errors - link