Equality vs Assignment

kpk at gitpyr.UUCP kpk at gitpyr.UUCP
Wed Sep 17 10:23:52 AEST 1986

Who among us has not been bitten at least once by writing

if (x = 1) ...

when he/she meant

if (x == 1)

What I want to know is

Has anyone written a program to scan a C program and issue a warning message
for those lines where an assignment has occured in a conditional statement
(i.e. if, while, the third statement in a for loop)?

If anyone has written such a program, why not post it (or at least mail me a

To any yacc and lex hacks: why not see if you can whip up such a program?

More information about the Comp.lang.c mailing list