Annotation of coherent/d/usr/src/examples/abs.c, revision 1.1

1.1     ! root        1: #include <ctype.h>
        !             2: #include <stdio.h>
        !             3: main()
        !             4: {
        !             5:        extern char *gets();
        !             6:        extern int atoi();
        !             7:        char string[64];
        !             8:        int counter;
        !             9:        int input;
        !            10: 
        !            11:        printf("Enter an integer: ");
        !            12:        fflush(stdout);
        !            13:        gets(string);
        !            14: 
        !            15:        for (counter=0; counter < strlen(string); counter++) {
        !            16:                input = string[counter];
        !            17:                if (!isascii(input)) {
        !            18:                        fprintf(stderr,
        !            19:                                "%s is not ASCII\n", string);
        !            20:                        exit(1);
        !            21:                }
        !            22:                if (!isdigit(input))
        !            23:                        if (input != '-' || counter != 0) {
        !            24:                                fprintf(stderr,
        !            25:                                        "%s is not a number\n", string);
        !            26:                                exit(1);
        !            27:                        }
        !            28:        }
        !            29: 
        !            30:        input = atoi(string);
        !            31:        printf("abs(%d) is %d\n", input, abs(input));
        !            32:        exit(0);
        !            33: }
        !            34: 

unix.superglobalmegacorp.com

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