Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: The final word on GOTO (Don't I wis Message-ID: <1236@virtech.UUCP> Date: 5 Oct 89 04:02:34 GMT References: <6396@ficc.uu.net> <725@thor.wright.EDU> Distribution: na Organization: Virtual Technologies Inc Lines: 26 In article <725@thor.wright.EDU>, bkottman@thor.wright.edu (Brett Kottmann) writes: > From article <6396@ficc.uu.net>, by peter@ficc.uu.net (Peter da Silva): > / The last time I looked at a stdio library there was a goto in _doprnt: > / > / [sample switch with gotos deleted] > / > This must be really old code since in C, execution falls through > to the next case anywasy; in every case without the goto, it would hit > donum: anyways...(albiet after trying the rest of the case statements) > A break usually replaces the goto in that type of code. The operations of a switch statement make a single comparison and jump to the specified case (or default). Once that jump has been made, there is no further "trying the rest of the case statements". without the listed gotos, the code would always act like the last case (base=16...). Since the entir code sample was not presented, one cannot guess as to the likelyhood that the goto's could easily be replaced with a break. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+