Annotation of researchv10no/games/fortune.oc, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: 
        !             3: char line[500];
        !             4: char bline[500];
        !             5: 
        !             6: main(argc, argv)
        !             7: char *argv[];
        !             8: {
        !             9:        register char * l;
        !            10:        int i;
        !            11:        long time();
        !            12:        FILE *f;
        !            13: 
        !            14:        l = "/usr/games/lib/fortunes";
        !            15:        if(argc > 1) {
        !            16:                l = argv[1];
        !            17:        }
        !            18:        f = strcmp(l, "-")? fopen(l, "r") : stdin;
        !            19:        if (f == NULL) {
        !            20:                printf("Memory fault -- core dumped\n");
        !            21:                exit(1);
        !            22:        }
        !            23:        srand((int)time(0));
        !            24:        for(i=1;; i++) {
        !            25:                l = fgets(line, 500, f);
        !            26:                if(l == NULL)
        !            27:                        break;
        !            28:                if(nrand(i) == 0)
        !            29:                        strcpy(bline, line);
        !            30:        }
        !            31:        fputs(bline, stdout);
        !            32:        return(0);
        !            33: }

unix.superglobalmegacorp.com

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