dmy (01/03/83)
I received 10 mail responses to my "Simple C Puzzle" posting. Almost everyone solved it. (I said it was simple.) One person used lint (try it), and another said some compilers would give a warning anyway. Comments ranged from "too easy" to "neat trick" to "my compiler produces 2" (so it's not only a legitimate puzzle, it's useful as a compiler test case). The solution (someone's already posted it) is that a/*p is parsed as "a" followed by the beginning of a comment, rather than as "a / *p" (which effect is achieved by the addition of propitious spacing). Thus the "++a" is part of a comment and not executed. The real "puzzle" was to invent such an ambiguous case without being too obvious about it. Any other interesting c (or inferior language) relatively short puzzles out there? Post to the net -- they are probably of general interest. (Don't bother plagarizing the Puzzle Book). --dmy--