[comp.lang.c] The Wizards' Quiz, UNIX Review March 1991.

peter@ficc.ferranti.com (Peter da Silva) (03/06/91)

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 <stdio.h>

	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?"