#include // so I don't have to do lo level io everywhere. #include #include // close, and in general #include //read #include //read #include //read #include // perror #include using namespace std; const char * filename = "scratch"; int main(int argc, char * argv[] ) { int fd; unsigned char x; int byte,i; for(i=1;i < argc; i++) { fd = open(argv[i], O_RDONLY); if (-1 == fd) { perror("Could not open file"); cout << "\t" << argv[i] << endl; } else { // the name of the file. cout << "File " << argv[i] << endl; byte = 0; // process all bytes in the file. while(read(fd, &x, 1)) { cout << setw(8) << byte << ": " << setw(3) << int(x); // print the character if it is printable. if (isprint(x)) { cout << " " << x; } cout << endl; byte ++; } close(fd); } // a blank line after each file cout << endl; } return 0; }