Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!zaphod.mps.ohio-state.edu!lavaca.uh.edu!menudo.uh.edu!sugar!ficc!peter From: peter@ficc.ferranti.com (Peter da Silva) Newsgroups: comp.lang.c Subject: The Wizards' Quiz, UNIX Review March 1991. Message-ID: Date: 5 Mar 91 17:42:11 GMT Organization: Xenix Support, FICC Lines: 36 In the latest UNIX review is a quiz on C programming. If this is what they call a "wizards' quiz" they have some might loopy wizards there... the very first question is not exactly wrong, but certainly dated. "The following code compiles OK. But it won't work correctly on most multiuser systems. Why? #include main() { char name[256]; printf("\nEnter your name: "); while((gets(name) == NULL) || (*name == NULL)) printf("\nName not entered correctly, re-enter: "); printf("Hello %s\check fontn", name); }" Well, apart from the formatting boners caused by running C code straight through nroff (I presume the last string should be "Hello %s\ncheck font\n"), I would say the biggest problem is the use of "gets", or the fact that it doesn't return an explicit exit status. But what do they pick? No fflush! How long has the smart stdio library been around? (yes, I know System V uses a totally boneheaded "line oriented" stdio, but that's a bug in and of itself... and I don't think it qualifies as "most multiuser systems") Sigh... The sixth question is about the UNIX "units" program. The seventh about /dev/tty. It goes quickly downhill from there... -- Peter da Silva. `-_-' peter@ferranti.com +1 713 274 5180. 'U` "Have you hugged your wolf today?"