This one bit me today

Fred Smith fredex at cg-atla.UUCP
Thu Oct 5 23:42:12 AEST 1989


In article <2432 at hub.UUCP> dougp at voodoo.ucsb.edu writes:
>-Message-Text-Follows-
>main()
>  {
>  int a=1,b=2,*p=&a,c;
>  c=b/*p;
>  }
>
>First real flaw in the C grammer I have found.




FLAME ON:

Just because C allows you to write terse, dense code, doesn't mean you should
actually DO it!

A much better (not to mention, more readable) way to write that would be:

c = b / *p;

or alternatively:

c = b / (*p);

With the second one you can leave out the spaces, which is your wont, even though
I think that it is easier to read with spaces around the operators and sub-expressions.

FLAME OFF:


Fred



More information about the Comp.lang.c mailing list