Annotation of 43BSDReno/usr.bin/learn/learnlib/C/L16.2a, revision 1.1

1.1     ! root        1: #print
        !             2: Write a program which reads a file with lines of up
        !             3: to 200 characters and shortens them to 60 characters
        !             4: by throwing away any characters past the first 60.
        !             5: Compile and test it; then type "ready".
        !             6: #once #create Ref
        !             7: hoboken harrison newark roseville avenue grove street
        !             8: east orange brick church orange highland avenue east orange 
        !             9: mountain station south orange maplewood millburn short hills
        !            10: summit chatham madison convent station morristown summit cha
        !            11: new providence murray hill berkeley heights
        !            12: 
        !            13: gillette stirling millingon lyons basking ridgexxxxxxxxxxxxx
        !            14: bernardsville far hills peapack gladstone
        !            15: #once #create badin
        !            16: hoboken harrison newark roseville avenue grove street
        !            17: east orange brick church orange highland avenue east orange brick church orange highland avenue east orange brick church orange highland avenue
        !            18: mountain station south orange maplewood millburn short hills
        !            19: summit chatham madison convent station morristown summit chatham madison convent station morristown summit chatham madison convent station morristown
        !            20: new providence murray hill berkeley heights
        !            21: 
        !            22: gillette stirling millingon lyons basking ridgexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        !            23: bernardsville far hills peapack gladstone
        !            24: #user
        !            25: a.out <badin >xxx
        !            26: #cmp Ref xxx
        !            27: #succeed
        !            28: /*     one way to do this */
        !            29:  #include <stdio.h>
        !            30: 
        !            31: main()
        !            32: {
        !            33:        char line[61];
        !            34:        int c, k;
        !            35: 
        !            36:        k = 0;
        !            37:        while ((c = getchar()) != EOF) {
        !            38:                if (c == '\n') {
        !            39:                        line[k] = 0;
        !            40:                        printf("%s\n", line);
        !            41:                        k = 0;
        !            42:                }
        !            43:                else if (k < 60)
        !            44:                        line[k++] = c;
        !            45:        }
        !            46: }
        !            47: 
        !            48: /* Note that this version works regardless of
        !            49: how long the lines are.  If you use getline,
        !            50: is the same thing true??
        !            51:  */
        !            52: #log
        !            53: #next
        !            54: 16.2b 10

unix.superglobalmegacorp.com

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