Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!condict From: condict@cs.vu.nl (Michael Condict) Newsgroups: comp.lang.c Subject: Re: Test of possible ACSGATE on net Message-ID: <3749@condict.cs.vu.nl> Date: 19 Oct 89 10:11:32 GMT References: <16103@nswitgould.cs.uts.oz> <647@targon.UUCP> Reply-To: condict@cs.vu.nl (Michael Condict) Organization: VU Informatica, Amsterdam Lines: 22 In article <647@targon.UUCP> andre@targon.UUCP (andre) writes: |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? | [ Horribly inefficient, unreadable program omitted ] |I'm going to be flamed for this but... | |main(c) |{ | while(read(0,&c,1)>0&&(c-' '?write(1,&c,1):1)) | ; |} And well you should be. All other considerations aside, your version won't work on machines where &c is the address of the most significant byte of c, rather than the least significant byte. On such machines you read each character into the most significant byte of c, then (c-' ') compares the least significant byte to ' '. Michael Condict Vrije University Amsterdam