Xref: utzoo misc.misc:5959 comp.misc:5960 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!apple!oliveb!cygnet!mark From: mark@cygnet.CYGNETSYSTEMS (Mark Quattrocchi) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <1383@cygnet.CYGNETSYSTEMS> Date: 5 May 89 21:53:37 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <11136@bloom-beacon.MIT.EDU> Reply-To: mark@cygnet.UUCP (Mark Quattrocchi) Organization: Cygnet Systems -- Sunnyvale, California Lines: 32 In article <11136@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <1814@ubu.warwick.UUCP> mirk@uk.ac.warwick.cs (Mike Taylor) writes: >>How many times have you seen this kind of code? >> >> printf ("Enter your sex: "); >> while (sex != "m" && sex != "f") { >> gets (sex); >> if (sex != "m" && sex != "f") >> printf (" or only: "); >> } > >Indeed, this is a pretty bad example of where a goto would be useful, >because you are simply illustrating what the purpose of the C do ... >while construct is for: > >do { > fprintf(stdout, "Enter your sex ( or only): "); > fflush(stdout); > fgets(stdin, sex, 2); > fflush(stdin); >} while ((*sex != 'm') && (*sex != 'f')); > >Granted, goto can have its uses, and exception handling is a prime >example, but don't go jumping to conclusions and saying that goto is >the most understandable method to use in a case where (at least in my >opinion) a more "structured" construct does a better job. > Speaking of jumping to conclusions, your code is not a one for one equivalent of the original. Even though I agree with your interpretation, you are cheating by combining the print statements together. Try again only don't cheat.