Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-b.proxad.net!nnrp13-2.free.fr!not-for-mail Message-ID: <4DFC928A.3050309@gmail.com> Date: Sat, 18 Jun 2011 13:56:58 +0200 From: Francois Grieu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.c To: lee Subject: Re: filters References: <87d3ibxx7e.fsf@yun.yagibdah.de> In-Reply-To: <87d3ibxx7e.fsf@yun.yagibdah.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Lines: 24 Organization: Guest of ProXad - France NNTP-Posting-Date: 18 Jun 2011 13:57:09 MEST NNTP-Posting-Host: 82.224.165.245 X-Trace: 1308398229 news-1.free.fr 32522 82.224.165.245:4538 X-Complaints-To: abuse@proxad.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:6350 On 18/06/2011 12:15, lee ask: > How do you go about writing a filter, i. e. a program that reads > data from stdin and processes it? #include int main(void) { int c; while(EOF!=(c = getchar())) { if (c>='0'&&c<='9') c = '9'-c+'0'; putchar(c); } } As an aside, I wonder if c = '9'-c+'0' is safe, and think c = '9'+'0'-c is not. Francois Grieu