Alien has asked for the wisdom of the Perl Monks concerning the following question:
If I enter something different than F,S or T , I get the message "(F)irst,(S)econd,(T)hird" printed more than it should.#include <stdio.h> int main() { char answer=' '; printf("(F)irst,(S)econd,(T)hird\n"); scanf("%c",&answer); while(answer !='F' && answer !='S' && answer !='T') { printf("(F)irst,(S)econd,(T)hird\n"); scanf("%c",&answer); } return 0; }
runs just fine .my $ans; print "(F)irst,(S)econd,(T)hird\n"; chomp($ans=<STDIN>); while($ans ne 'F' && $ans ne 'S' && $ans ne 'T') { print "(F)irst,(S)econd,(T)hird\n"; chomp($ans=<STDIN>); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does perl get this right and C doesn't ?
by Joost (Canon) on Nov 28, 2007 at 21:26 UTC | |
|
Re: Why does perl get this right and C doesn't ?
by Fletch (Bishop) on Nov 28, 2007 at 21:27 UTC | |
|
Re: Why does perl get this right and C doesn't ?
by tuxz0r (Pilgrim) on Nov 28, 2007 at 22:38 UTC |