Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!asuvax!ukma!psuvax1!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Two points Message-ID: <15727@smoke.brl.mil> Date: 5 Apr 91 23:39:45 GMT References: <3646@inews.intel.com> <15705@smoke.brl.mil> <3661@inews.intel.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 12 In article <3661@inews.intel.com> bhoughto@hopi.intel.com (Blair P. Houghton) writes: >In article <15705@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >>In article <3646@inews.intel.com> bhoughto@nevin.intel.com (Blair P. Houghton) writes: >>> while ( ( c = (char) getchar() ) != (char)EOF ) >>Assuming that the loop is meant to handle all possible byte values, >>this is also buggy. By the way, the reason I harp on this particular example is because I have seen a LOT of code fail due to exactly this (and the previous) construct. getchar() returns an int; therefore it is that int value that should be tested against EOF before any possible conversion to a char (which may or not be signed). It is easy to get this right..