Have a look at the diff and tell me the logical difference that I don't see. Run the programs as: echo 1 2 3 4 | ./scanf1 and echo 1 2 a 4 | ./scanf1 to see the problem. scanf2 works as expected. The assembler code was generated with cc -O0 scanf1.c -c -S -o scanf1.s Unfortunately, I'm pretty poor at assembler. The diffs are for your convenience. 2009-10-27 markus schnalke