Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.co.jp (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: Test of possible ACSGATE on net Message-ID: <10966@riks.csl.sony.co.jp> Date: 17 Oct 89 01:57:34 GMT References: <16103@nswitgould.cs.uts.oz> Reply-To: /dev/null Followup-To: /dev/null Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 25 In article <16103@nswitgould.cs.uts.oz> garth_kidd%680.808@fidogate.fido.oz (Garth Kidd) writes: >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)) > ; >} Yeah! Strip the spaces from it!!!!!! (Oh by the way, a zillion calls to "getc" are faster than a zillion 1-byte calls to "read", and the same for half-a-zillion calls to "putc" although you'll have to move your (ch==' ')?0:xxxx test around in front of the "putc. But this doesn't make it tighter.) -- Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work) Should the preceding opinions be caught or | James Bond asked his killed, the sender will disavow all knowledge | ATT rep for a source of their activities or whereabouts. | licence to "kill".