Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.7.0.8 $; site ndm20
Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!convex!ndm20!tp
From: tp@ndm20
Newsgroups: net.lang.c
Subject: Re: C Style
Message-ID: <3400007@ndm20>
Date: Mon, 16-Sep-85 12:30:00 EDT
Article-I.D.: ndm20.3400007
Posted: Mon Sep 16 12:30:00 1985
Date-Received: Sun, 29-Sep-85 04:47:05 EDT
References: <180@chinet.UUCP>
Lines: 31
Nf-ID: #R:chinet.UUCP:-18000:ndm20:3400007:000:704
Nf-From: ndm20!tp    Sep 16 11:30:00 1985


> 
>> 	for ( ; (((ch=getch()) < '1' || ch > '5') && ch != 'E') ; )
>> 		putchar(BELL);
>> 	addch(ch);
>> 	refresh();
>> 
>
>I suggest a more appropriate construct, the 'while' loop:
>
>	while(( ch =  getch()) != EOF )
>	{
>		if(( ch < '1' || ch > '5') && ch != 'E')
>			putchar( BELL );
>		addch( ch );
>		refresh();
>	} /* end while */
The second loop does not do the same thing as the first. A better construct
is:

 	for (ch=getch() ; ((ch < '1' || ch > '5') && ch != 'E') ; ch=getch())
 		putchar(BELL);
 	addch(ch);
 	refresh();

Terry Poot
Nathan D. Maier Consulting Engineers
(214)739-4741
Usenet: ...!{allegra|ihnp4}!convex!smu!ndm20!tp
CSNET:  ndm20!tp@smu
ARPA:   ndm20!tp%smu@csnet-relay.ARPA