The final word on GOTO (Don't I wis
Blair P. Houghton
bph at buengc.BU.EDU
Fri Oct 6 15:17:38 AEST 1989
In article <6430 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
>Code deleted, see parent article.
>Here's a goto-less version of the multiple
>lead-in case that should have you all puking:
Hwuawp! Thanks, Pete. Had the wrong thing for lunch, anyway... :-)
> switch(format_char) {
> case 'd': the stuff I put under d; if(0) {
> case 'o': the stuff I put under o; if(0) {
> case 'x': the stuff I put under x; if(0) {
> case 'u': the stuff I put under u; }}}
> the stuff I put under donum;
> }
>
>I know it's not the best way to remove the gotos, but it's legal C
>without a single "unstructured" element.
I'd go out of my way to fix it so that I could just do
switch(format_char) {
case 'd': the stuff I put under d; break;
case 'o': the stuff I put under o; break;
case 'x': the stuff I put under x; break;
case 'u': the stuff I put under u; break;
}
the stuff I put under donum;
Even if it meant (Gasp!) declaring a few variables outside the
switch and structuring the rest of my program in such a way
as to prevent needing such kludgery...
--Blair
"At least they'd get
initialized properly..."
More information about the Comp.lang.c
mailing list