On Jun 16, 2009, at 10:30 AM, Gary Kline wrote:
I thought my initial getchar() != EOF would handle that.
But then there's that do-forever loop.
As I said, the most common problem people had was failing to check of
EOF in all the places it could occur, and so looping forever.
Do not rely on the input being well formed.
I remember Jeffrey's
post and tried a case 'EOF' or case '-1'; thar gives me
compiler errors.
Look at the man page for getchar() paying close attention to the type
of what it returns.
You should really take the pointers from Jeffrey Goldberg and
record states
and decide based on the state, rather then inlined switch
statements, if only
for readability.
Even for a very simple task, the logic of your code is very very hard
to read. Clarify the logic (using the idea of a "state") and you will
find that this can be programmed very simply.
-j
--
Jeffrey Goldberg http://www.goldmark.org/jeff/
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"