#include unsigned int bytecnt = 0; int parerr(unsigned char c) { unsigned int i; unsigned int accum = 0; for(i = 0; i<8; i++){ accum += (c&1); c = c >> 1; } if(accum &1) return(0); // odd parity else return(1); // even parity } main() { unsigned int wrdcnt = 0; unsigned int i; unsigned int c; unsigned int pos = 0; int eob = 0; do { c = getchar(); if(feof(stdin)) exit(); bytecnt++; if(c == 0){ if(eob == 0) { eob++; pos = 0; printf("\nnul at %d\n", bytecnt); } continue; } eob = 0; i = (c & 0x3f) << 18; if(parerr(c)){ printf("parity error byte %d val %x\n", bytecnt, c); } c = getchar(); if(feof(stdin)) exit(); bytecnt++; if(c == 0){ continue; } i = i | ((c & 0x3f) << 12); if(parerr(c)){ printf("parity error byte %d val %x\n", bytecnt, c); } c = getchar(); if(feof(stdin)) exit(); bytecnt++; if(c == 0){ continue; } i = i | ((c & 0x3f) << 6); if(parerr(c)){ printf("parity error byte %d val %x\n", bytecnt, c); } c = getchar(); if(feof(stdin)) exit(); bytecnt++; if(c == 0){ continue; } i = i | (c & 0x3f); if(parerr(c)){ printf("parity error byte %d val %x\n", bytecnt, c); } wrdcnt++; pos++; printf("%08o ", i); if((pos % 8) == 0) printf("\n"); fflush(stdout); } while (!feof(stdin)); printf("\n"); }