#include #include #include int main(int argc, char *argv[]) { int fd; unsigned char tally = 0; unsigned char next = 0; if (argc!=2) return -1; fd = open(argv[1], O_RDWR|O_APPEND); if (fd<0) return -2; while (read(fd, &next, 1)) { //printf("Tally: %X, next byte: %X\n", tally, next); tally ^= next; }; printf("Final tally: %X\n", tally); write(fd, &tally, 1); close(fd); return 0; }