the default of a switch
Blair P. Houghton
bph at buengc.BU.EDU
Fri Mar 10 04:25:07 AEST 1989
In article <10833 at pasteur.Berkeley.EDU> klatchko at cory.Berkeley.EDU (ron klatchko) writes:
>In a C switch statement, if you have a 'default' part, does it have
>to go below all the 'case' parts? As a matter of style, I know it
>should, but how about offical C syntax? How about the ANSI standard?
>Thanks.
The ref pages in K&R I are not specific. I assume that means You Can
Put it Anywhere within the scope of the switch. You can do the same
with the 'case:' statements, too, although the status of
'case const-expr: statememt' as a statement itself means that you can
make 'case const-expr: statement' part of the 'statement' in
a preceding 'case const-expr: statement', effectively creating the
fall-through execution we're all familiar with.
Do K&R II or the pANS say anything more restrictive
about 'default: statement' ?
(Ten seconds and one index-dereferencing later...)
Sorry. "RTFM, Blair!" Page 55, K&R I, second-to-last sentence, says,
"Cases and default can occur in any order."
--Blair
"Ready everyone? In your
best Emily Litella voice:
'never mind.'"
More information about the Comp.lang.c
mailing list