Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!agate!ig!uwmcsd1!bbn!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: C Quirk?? Summary: y Message-ID: <885@PT.CS.CMU.EDU> Date: 17 Feb 88 14:27:30 GMT References: <1653@ssc-vax.UUCP> <804@PT.CS.CMU.EDU> <23498@hi.unm.edu> <186@ateng.UUCP> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 15 > > > >#define clearline() while (getchar() != '\n') > > This is seriously bad code. What if stdin reaches end of file? > It loops forever -- oops. Change that to #define clearline() while (1) {int ch = getchar(); \ if ((ch == EOF) || (ch =='\n')) break; } -- Eddie Wyatt e-mail: edw@ius1.cs.cmu.edu