Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mmm!mkr From: mkr@mmm.UUCP (MKR) Newsgroups: net.lang.c Subject: Re: Switch case common code Message-ID: <953@mmm.UUCP> Date: Thu, 19-Jun-86 14:31:26 EDT Article-I.D.: mmm.953 Posted: Thu Jun 19 14:31:26 1986 Date-Received: Sun, 22-Jun-86 04:26:43 EDT References: <605@cisden.UUCP> <134@danews.UUCP> Reply-To: mkr@mmm.UUCP (MKR) Organization: none Lines: 49 In article <134@danews.UUCP> lvc@danews.UUCP (Larry Cipriani) writes: >The 'best' I think that can be done is to do something like: > > switch (switch_variable) > { > case a: ... > ... > goto common; > break; > > case b: ... > ... > common: common_code_for_a_and_b > break; > > case c: ... > ... > break; > } > >Larry Cipriani AT&T Network Systems Why not: int common_stuff() { blahblahblah } main() { ... switch (thnad) { case A: do the A stuff; common_stuff(); break; case B: do the B stuff; common_stuff(); break; case C: do the C stuff; break; } I thought that's what functions were for. --MKR