The final word on GOTO (Don't I wis
Brett Kottmann
bkottman at thor.wright.edu
Thu Oct 5 04:51:14 AEST 1989
>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:
/
/ if you see a %
/ handle number.number stuff
/ see what the format is
/
/ switch(format) {
/ case 'd':
/ base = 10;
/ if(number < 0) {
/ sign = '-';
/ number = -number;
/ } else
/ sign = 0;
/ ...
/ goto donum;
/ case 'u':
/ base = 10;
/ sign = 0;
/ ...
/ goto donum;
/ case 'o':
/ base = 8;
/ sign = 0;
/ ...
/ goto donum;
/ case 'x':
/ base = 16;
/ sign = 0;
/ ...
/ goto donum;
/ donum:
/ format number with base, sign, etc.
/
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.
More information about the Comp.lang.c
mailing list