#include #include #include "getch.h" #define MAXLINE 80 #define OCTLEN 6 int inc(int col, int n); int main(void) { char c, col, next; col = 0; while ((c = getch()) != EOF) { if (iscntrl(c) || isblank(c)) { col = inc(col, OCTLEN); printf(" \\%03o ", c); if (c == '\n') { col = 0; putchar(c); } } else { col = inc(col, 1); /* ac- * k */ ungetch(next = getch()); if (col == MAXLINE && isalpha(c) && isalpha(next)) { ungetch(c); c = '-'; } putchar(c); } } return 0; } int inc(int col, int n) { if (col + n > MAXLINE) { putchar('\n'); return n; } else { return col + n; } }