Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: the default of a switch Message-ID: <2226@buengc.BU.EDU> Date: 9 Mar 89 18:25:07 GMT References: <10833@pasteur.Berkeley.EDU> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 25 In article <10833@pasteur.Berkeley.EDU> klatchko@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.'"