diff --git a/charhist/GNUmakefile b/charhist/GNUmakefile new file mode 100644 index 0000000..574c244 --- /dev/null +++ b/charhist/GNUmakefile @@ -0,0 +1,10 @@ +include GNUmakevars +include GNUmakerules + +all: charhist + +chartab: +clean: + rm -f charhist core foo bar baz + +install: $(BINDIR)/charhist diff --git a/charhist/charhist.c b/charhist/charhist.c new file mode 100644 index 0000000..0017be8 --- /dev/null +++ b/charhist/charhist.c @@ -0,0 +1,19 @@ +#include +#include +#include + +long hist[UCHAR_MAX+1]; + +int main (int argc, char **argv) { + int c; + + while ((c = getchar()) != EOF) { + hist[c]++; + } + for (c = 0; c <= UCHAR_MAX; c++) { + if (hist[c]) { + printf ("%x %d %o %c\t%ld\n", c, c, c, isprint(c) ? c : '.', hist[c]); + } + } + return 0; +}