switch statement

John Hascall hascall at cs.iastate.edu
Wed Mar 14 06:14:43 AEST 1990


/* If you REALLY hate fall-through on switch statements... */

#define when       break;case
#define or         : case
#define otherwise  break;default

void whatsit(char ch) {

        switch(ch) {
                when 'a' or 'e' or 'i' or 'u':
                        printf("it's a vowel\n");
                when 'y':
                        printf("it might be a vowel\n");
                otherwise:
                        printf("it's not a vowel\n");
        }
}
/* John Hascall  /  ISU Comp Ctr  /  hascall at atanasoff.cs.iastate.edu */



More information about the Comp.lang.c mailing list