Annotation of 3BSD/games/fortune.c, revision 1.1

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

unix.superglobalmegacorp.com

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