Annotation of 42BSD/usr.lib/learn/C/L19.1a, revision 1.1.1.1

1.1       root        1: #print
                      2: Write a subroutine which counts the number of times it has
                      3: been called and returns that count each time.  Name it
                      4: "count()".  Write it on a file named "count.c".  Compile
                      5: and test it; type "ready" when happy.
                      6: #once #create Ref
                      7: 23080
                      8: #once #create tzaqc.c
                      9: main() {
                     10:        int i;
                     11:        for (i = 0; i < 23079; i++)
                     12:                count();
                     13:        printf("%d\n", count());
                     14: }
                     15: #user
                     16: cc tzaqc.c count.o
                     17: a.out  >value
                     18: #cmp value Ref
                     19: #succeed
                     20: /*  one way */
                     21: count()
                     22: {
                     23:        static int n = 0;
                     24:        return(++n);
                     25: }
                     26: #log
                     27: #next
                     28: 30.1a 10
                     29: 20.1a 5

unix.superglobalmegacorp.com

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