Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!bloom-beacon!spdcc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: Test of possible ACSGATE on net Message-ID: <721@lakart.UUCP> Date: 17 Oct 89 14:35:08 GMT References: <13130@orstcs.CS.ORST.EDU> Organization: Lakart Corporation, Newton, MA Lines: 30 garth_kidd%680.808@fidogate.fido.oz (Garth Kidd) sez: >Can anyone think of a tighter way of coding a filter to strip spaces >from the input stream than this? > >main() >{ > char ch; > > for(;read(0,&ch,1)==1;write(1,&ch,(ch==' ')?0:1)) > ; >} #include main() { int ch; while ((ch = getchar()) != EOF) if (ch != ' ') putchar(ch); } However, contemplate what will happen to the correctness of either of the above programs if passed through such a filter. They will _BOTH_ break, either failing to compile or generating incorrect code if they do compile. -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+