C puzzle

thomas at advent.uucp thomas at advent.uucp
Tue Jun 18 08:44:11 AEST 1991


	The following is an interesting 'C' puzzle. 
	Consider this typical switch statement, typical except that 
	'default' is misspelled 'defalut'! What is interesting is that
	any C compiler will not and should not give you a syntax error. 
	Why?  


	switch (cmd)
	{
		case GO:
			...
			break;
		case STOP:
			...
			break;
		defalut:
			printf ("Unknown command\n");
			break;
	}

	(Hint: It is bad programming practice to jump into the 
	middle of a switch statement.)

thomas



More information about the Comp.lang.c mailing list