I'm using the following code to open a file, read char by char and get the char number as hexadecimal. The problem is that the loop never ends. What is wrong with it?
Is file >> x the equivalent to x = file.get()?
ifstream file;
    file.open(argv[1], ifstream::in|ifstream::binary);
    if (file.is_open())
    {
        unsigned char x;
        file >> std::noskipws;
        while (file >> x) {
            stringstream s;
            s << std::hex << std::setw(2) << std::setfill('0')
                << (int)x;
            std::cout << s.str();
        }
        file.close();
    }
