#include <iostream>

using std::cin;
using std::cout;
using std::ios;

int main()
{
    for (;;) {
        int value = 0;

        // Interpret 0 and 0x as hexadecimal and octal prefixes.
        // No prefix still means "decimal" integer
        // For example, try
        // 0 0x(error) 123 -123 -0777, 0888(decimal 888) 0xA -0xA -0x(error)
        //cin.unsetf( ios::dec );

        // Ignore octal prefix, for example,
        // interpret 077 as decimal 77
        //cin.unsetf( ios::oct );

        // All integers now expected to be octal base:
        //cin.unsetf( ios::dec );
        //cin.setf( ios::oct );

        // All integers now expected to be base-16:
        // Interpret 12 as hexadecimal
        // Interpret 0x12 as hexadecimal
        // Interpret 077 as hexadecimal
        //cin.unsetf( ios::dec );
        //cin.setf( ios::hex );

        if ( !( cin >> value ) ) {
            // cin is not good, some checks required...
            if ( cin.bad() ) {
                cout << "\t\tStream is corrupted, exiting\n";
                return 1;
            }
            if ( cin.eof() ) {
                cout << "\t\tEOF, exiting\n";
                return 0;
            }
            if ( cin.fail() ) {
                cin.clear(); // go back to good state...
                cout << "\t\tInput formatting failed, recovering...\n";
                char ch = 0;
                while ( cin >> ch ) {
                    if ( isdigit( ch ) ) {
                        cin.unget(); // put the digit back
                        break;
                    }
                    cout << "\t\tCharacter [" << ch << "] was ignored\n";
                }//while
                continue; // back to reading the value
            }
        }
        cout << "\tvalue == " << value << ";\n";
    }//for
    return 0;
}