Test of possible ACSGATE on net

andre andre at targon.UUCP
Thu Oct 19 00:49:26 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))
>    ;
>}

I'm going to be flamed for this but...

main(c)
{
  while(read(0,&c,1)>0&&(c-' '?write(1,&c,1):1))
    ;
}

-- 
The mail|    AAA         DDDD  It's not the kill, but the thrill of the chase.
demon...|   AA AAvv   vvDD  DD        Ketchup is a vegetable.
hits!.@&|  AAAAAAAvv vvDD  DD                    {nixbur|nixtor}!adalen.via
--more--| AAA   AAAvvvDDDDDD    Andre van Dalen, uunet!hp4nl!targon!andre



More information about the Comp.lang.c mailing list