Xref: utzoo misc.misc:6102 comp.misc:6067 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!texsun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!luuk From: luuk@cs.vu.nl (Luuk Uljee) Newsgroups: misc.misc,comp.misc Subject: Re^2: The "evil" GOTO (Was: 25 Years of BASIC) Message-ID: <2491@koto.cs.vu.nl> Date: 11 May 89 01:21:18 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <1814@ubu.warwick.UUCP> <1860@ubu.warwick.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 42 geoff@cs.warwick.ac.uk (Geoff Rimmer) writes: >Here is my solution. Which does the same as that of the original >poster, and in addition: >(a) it checks the buffer overflowing; >(b) it checks for EOF >(c) it is correct C code >----------------------------------------------------------------------------- >#include >main() >{ > char str[4]; > printf("Enter your sex: "); > do > { > fflush(stdin); > if (!fgets(str,3,stdin)) exit(1); > } while (*str!="m" && *str!="f") ? printf("m or f only: "):0); > printf("sex is %c\n",*str); >} >----------------------------------------------------------------------------- Hey, you probably never done any programming in LISP! Otherwise you would have known of an option 'showmatch' in vi :-) (BEEP) ... Besides that, this code contains still all off the unstructered ugliness - jumping out of a loop (exit) - no comments (no comment) - inconsistent use of return value (printf) - comparison of unequal types (sometimes there is really no need for comments) - Use of unexplained arbitrary constants (4) - etc etc ... |cc% cc -c c.c | Luuk Uljee |"c.c", line 1989: invalid identifier "goto" | email: luuk@cs.vu.nl | "How bright the future could be ..... " | (I knew it was a joke Geoff ... )