more about programming style

Philip Lantz philipl at azure.UUCP
Wed Aug 7 15:55:13 AEST 1985


> Perhaps I'm being a bit sarcastic, but could it be that the reason experienced
> C programmers often use
> 
> 	if ((fp = fopen("file", "r")) == NULL) ...
> 
> is that the compiler will complain if you write
> 
> 	if ((fp = fopen("file", "r")) = NULL) ...
> 
> whereas it won't complain about
> 
> 	fp = fopen("file", "r");
> 	if (fp = NULL) ...
> 
> ???

Sure it will; at least PCC-based compilers will say "statement not reached".



More information about the Comp.lang.c mailing list