Always use braces
    Frans van Otten 
    fransvo at htsa.uucp
       
    Tue Jan  3 18:27:20 AEST 1989
    
    
  
In article <9235 at smoke.BRL.MIL> gwyn at brl.arpa writes:
>	#include	<stdio.h>
>	#define	MAGIC	'\0'	/* silly terminating character value */
>	int			/* returns EOF or MAGIC (why??) */
>	some_function( void )	/* ANSI C assumed; else delete "void" */
>		{
>		int	c;	/* character from standard input */
>		while ( (c = getchar()) != EOF )
>			if ( c == MAGIC )
>				return MAGIC;
>		return EOF;
>		}
How do you like it my way:
#include <stdio.h>
int f()
  { int ch;
    while ((ch = getchar()) != EOF  &&  c)    /*  find EOF or '\0'  */
    return (ch);
  }
Any C programmer will understand how this function works; it takes less
space, because it is shorter, etc. So: Why is my solution too simple ?
-- 
                         Frans van Otten
                         Algemene Hogeschool Amsterdam
			 Technische en Maritieme Faculteit
                         fransvo at htsa.uucp
    
    
More information about the Comp.lang.c
mailing list