#include <cctype>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(int argc, char **argv)
try
{
    if (argc == 1)
        throw 1;

    ifstream in{ argv[1] };

    if (not in)
        throw 1;

    string control{ "\n\t\r" };

    size_t idx = 0;
    while (true)
    {
        int ch = in.get(); 
        if (ch == EOF)
            break;

        if (not isprint(ch) and control.find(ch) == string::npos)
            throw idx;
        ++idx;
    }

    cout << "ASCII text file\n";
    return 0;
}
catch (size_t idx)
{
    cout << "other file type at idx " << idx << "( 0x" << hex << idx << ")\n";
}



