The final word on GOTO (Don't I wis

Conor P. Cahill cpcahil at virtech.UUCP
Thu Oct 5 14:02:34 AEST 1989


In article <725 at thor.wright.EDU>, bkottman at thor.wright.edu (Brett Kottmann) writes:
> From article <6396 at ficc.uu.net>, by peter at 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     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list