The Sins of K&R
Christopher R Volpe
volpe at underdog.crd.ge.com
Thu Sep 27 05:23:36 AEST 1990
In article <31604 at nigel.ee.udel.edu>, shearer at cis.udel.edu (Rob Shearer)
writes:
|>
|>I do this alot:
|>
|> ch = getch();
|> switch (ch) {
|> case 'q':
|> case 'Q':
|> case 27 :
|> case 13 :
|> exit_menu = 1;
|> break;
|> case 'a':
|> do_a(); break;
|> ...etc
|> }
How about combining the "let's make break implicit" idea with the
"lets add ranges and lists" idea and solve everybody's problems? E.g.:
ch = getch();
switch (ch) {
case 'q','Q',27,13:
exit_menu=1;
case 'a':
do_a();
...etc
}
Now, a break within a case can be used to break out of an enclosing loop,
and the "multi-case" capability is still maintained.
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com
More information about the Comp.lang.c
mailing list