Annotation of coherent/d/usr/src/examples/goto.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: 
                      3: main()
                      4: {
                      5:        char line[80];
                      6: 
                      7:        getline:
                      8:                printf("Enter line: ");
                      9:                fflush(stdout);
                     10:                gets(line);
                     11: 
                     12: /* a series of tests often is best done with goto's */
                     13:        if (*line == 'x') {
                     14:                printf("Bad line\n");
                     15:                goto getline;
                     16:        } else 
                     17:                if (*line == 'y') {
                     18:                        printf("Try again\n");
                     19:                        goto getline;
                     20:                } else 
                     21:                        if (*line == 'q')
                     22:                                goto goodbye;
                     23:                        else
                     24:                                goto getline;
                     25: 
                     26:        goodbye:
                     27:                printf("Goodbye.\n");
                     28: }

unix.superglobalmegacorp.com

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