Perhaps I misunderstood Simon's intent, but I thought his code which
verged on obfuscation (IMHO), did no error handling and threw away the
data it found was quite amusing. The fact that the original poster
seemed to like it amused me even more.
You may have a different point of view.
Here, for reference, is Simon's main loop:-
for(n = 0;
n < 10 && scanf("%d", &i) == 1;
n += -399 <= i && i <= 400);
Yes, it is mildly obfuscated. It's not that difficult to follow though:
a loop on the variable n usually takes the form:
for(n = 0; n < maximum; n += increment);
I have added another condition: that the return value of scanf is one.
The increment is a little complex, since the value is the boolean result
of whether the read value i is in the correct range: 0 for no (in which
case n is unchanged) and 1 for yes (in which case n is incremented).
There _is_ error handling. The program checks the return value of scanf.
If a matching error occurs, then the loop is ended without going on to
the 'increment' portion. So it avoids reading the invalid/uninitialised
value of i.
If you wanted to do something with the read values, such as printing
them, storing them, passing them to a function, etc., all you need do is
add that code to the, currently empty, body of the loop.