Xref: utzoo misc.misc:5925 comp.misc:5941 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!garnet.berkeley.edu!ked From: ked@garnet.berkeley.edu (Earl H. Kinmonth) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <24047@agate.BERKELEY.EDU> Date: 5 May 89 02:57:55 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <11136@bloom-beacon.MIT.EDU> Sender: usenet@agate.BERKELEY.EDU Organization: University of California, Berkeley Lines: 25 >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')); First, your C compiler must have a rather weird stdio library if it requires you to to do explicit flushing. Second, why not while(1) { fputs("Sex (m or f) ",stdout); gets(ls); if(ls[0] == 'm') return(ls[0]); else if(ls[0] == 'f') return(ls[0]); } as a subroutine?