Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ncar!gatech!mcnc!decvax!ima!mirror!frog!john From: john@frog.UUCP (John Woods) Newsgroups: comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Message-ID: <1407@frog.UUCP> Date: 9 May 89 05:37:00 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1191@aplcen.apl.jhu.edu> Organization: Misanthropes-R-Us Lines: 36 In article <1191@aplcen.apl.jhu.edu>, arrom@aplcen.apl.jhu.edu (Ken Arromdee) writes: > >do { < > fprintf(stdout, "Enter your sex ( or only): "); > > fflush(stdout); < > fgets(stdin, sex, 2); > > fflush(stdin); < >} while ((*sex != 'm') && (*sex != 'f')); > < This is not analogous. > < The original example prints the " or only:" message only if the > input is not an "m" or "f". This supposeedly analogous program prints it < every time. > Exactly. That is why the second program is better. It encourages the desired response the first time around. That kind of software ENGINEERING goes against the grain of BASIC programming, however :-). If you really must have the original confusing prompt structure, fill in the blanks: printf(_); while (1) { gets(_); if (_) break; printf(_); } Voila! The loop-and-a-half. -- John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101 ...!decvax!frog!john, john@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu Fellow cranks!! ...I'm not ALONE!!