Xref: utzoo misc.misc:6057 comp.misc:6038 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!philmtl!philabs!ttidca!hollombe From: hollombe@ttidca.TTI.COM (The Polymath) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <4397@ttidca.TTI.COM> Date: 9 May 89 20:38:11 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <11136@bloom-beacon.MIT.EDU> <1383@cygnet.CYGNETSYSTEMS> Reply-To: hollombe@ttidcb.tti.com (The Polymath) Organization: The Cat Factory Lines: 41 In article <1383@cygnet.CYGNETSYSTEMS> mark@cygnet.UUCP (Mark Quattrocchi) writes: }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')); }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. This isn't cheating. Both code fragments accomplish the same function -- getting the user's sex. The second fragment does it better on several counts. Not only is the code simpler, more efficient and easier to maintain, but it helps prevent the end user from making an avoidable error. Human factors is part of programming. -- The Polymath (aka: Jerry Hollombe, hollombe@ttidca.tti.com) Illegitimati Nil Citicorp(+)TTI Carborundum 3100 Ocean Park Blvd. (213) 452-9191, x2483 Santa Monica, CA 90405 {csun|philabs|psivax}!ttidca!hollombe