/* prog to count characters by hex values and output a table
 * of same; reads from stdin; to use with a file 'fname' invoke
 * as:
 *     countchar <fname
 * and to sort output into order of frequency, pipe as in:
 *     countchar <fname | sort -n +1
 * and you can then pipe that into other tools....
 *
 * To compile, try:
 *     cc countchar.c -o countchar
 * so that the output executable is named "countchar"
 *
 * ^z - 19951015
 */

#include <stdio.h>
main () {
  long a[256];
  int i;
  unsigned int c;

  for (i = 0; i < 256; ++i)
    a[i] = 0;

  while ((c = getchar()) != EOF)
    ++a[c];

  for (i = 0; i < 256; ++i)
    printf ("%3d %10ld\n", i, a[i]);
}

