The Sins of K&R
Jeffrey T. Hutzelman
jh4o+ at andrew.cmu.edu
Fri Sep 28 14:52:14 AEST 1990
volpe at underdog.crd.ge.com (Christopher R Volpe) writes
> Ok, how about requiring the programmer to make it explicit when
> he/shewants it to fall through, rather than making that the default?
> Like so:
>
>switch(ch)
> {
> case 'a':
> do_a();
> continue;
> case 'b':
> do_a_or_b();
> }
No!!! I LIKE being able to do the following:
void some_func(void)
{
while(1) { /* because people don't seem to like for(;;) */
/* something to get a key - that's machine specific */
switch (key)
{
case '1':
action_1();
break;
case '2':
action_2();
break;
case 'q':
return;
default:
putc('\007'); /* BEEP */
continue; /* SKIP the stuff after the swicth */
}
/* now, do some things to be done ONLY if a selection was made,
like redrawing the menu after a function has been performed */
}
}
-----------------
Jeffrey Hutzelman
America Online: JeffreyH11
Internet/BITNET:jh4o+ at andrew.cmu.edu, jhutz at drycas.club.cc.cmu.edu
>> Apple // Forever!!! <<
More information about the Comp.lang.c
mailing list