Furthermore, the %X format specifier for printf tells printf that you're feeding it an unsigned int type. If you're feeding it a char as in the original code the argument will be promoted to an int, which is not an unsigned int. If you're feeding it an unsigned char as in vin's code, it will be promoted to an unsigned int which is the correct type. I do believe I would be a little more explicit in the casting, though: printf("%02X ", (unsigned)uc);.
Edit: Of course the C++ way of doing this is less prone to error.