Annotation of researchv10no/cmd/lcc/tst/cf.c, revision 1.1

1.1     ! root        1: /* cf - print character frequencies */
        !             2: float f[128];
        !             3: 
        !             4: main(argc, argv)
        !             5: int argc;
        !             6: char *argv[];
        !             7: {
        !             8:        int i, c, nc;
        !             9:        float cutoff, atof();
        !            10: 
        !            11:        if (argc <= 1)
        !            12:                cutoff = 0.0;
        !            13:        else
        !            14:                cutoff = atof(argv[1])/100;
        !            15:        for (i = 0; i <= 127; )
        !            16:                f[i++] = 0.0;
        !            17:        nc = 0;
        !            18:        while ((c = getchar()) != -1) {
        !            19:                f[c] += 1;
        !            20:                nc++;
        !            21:        }
        !            22:        printf("char\tfreq\n");
        !            23:        for (i = 0; i <= 127; ++i)
        !            24:                if (f[i] && f[i]/nc >= cutoff) {
        !            25:                        if (i <= ' ')
        !            26:                                printf("%03o", i);
        !            27:                        else
        !            28:                                printf("%c", i);
        !            29:                        printf("\t%.1f\n", 100*f[i]/nc);
        !            30:                }
        !            31:        return 0;
        !            32: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.