/* File charlist.c * Aronsson was here * 7 April 1993 * * Read a file from stdin * Print to stdout a list of octal char values that occur in the file */ #include int main (int argc, char *argv[]) /* Ignore arguments */ { char clist[256]; int c; for (c = 0; c < 256; c++) /* reset */ clist[c] = 0; while (EOF != (c = getchar ())) /* process input */ clist[c] = 1; for (c = 0; c < 256; c++) /* report results */ { if (! clist[c]) /* no occurances */ continue; if (c + 1 < 256 && clist[c + 1]) { printf ("%o-", c); /* first in an interval */ while (c + 1 < 256 && clist[c + 1]) c++; } printf ("%o,", c); /* single or last */ } putchar ('\n'); return 0; }