Using %c suppresses the skipping of whitespace charaters in a scanf, which is causing your newline to get read by subsequenet scanf calls in the while, throwing off your expected results. Plus, using %s lets you more easily handle ANY line of input, since you can then strip leading, trailing white space and more to get the character you want (meaning you'll have to change your check for characters in the while).char answer[1024]; ... scanf("%s\n", answer); ...
---
echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.
In reply to Re: Why does perl get this right and C doesn't ?
by tuxz0r
in thread Why does perl get this right and C doesn't ?
by Alien
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |