Test of possible ACSGATE on net

Norman Diamond diamond at csl.sony.co.jp
Tue Oct 17 11:57:34 AEST 1989


In article <16103 at nswitgould.cs.uts.oz> garth_kidd%680.808 at 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 at 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".



More information about the Comp.lang.c mailing list