C Style
tp at ndm20
tp at ndm20
Tue Sep 17 02:30:00 AEST 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 at smu
ARPA: ndm20!tp%smu at csnet-relay.ARPA
More information about the Comp.lang.c
mailing list