Quote Originally Posted by sand_man
Code:
if(scanf("%d",&var) != 2)
{
   ... //var is not 2
}
I think that is right
Close. From the man page:
RETURN VALUES

These functions return the number of input items assigned,
which can be fewer than provided for, or even zero, in the
event of a matching failure. Zero indicates that, while
there was input available, no conversions were assigned;
typically this is due to an invalid input character, such
as an alphabetic character for a `%d' conversion. The
value EOF is returned if an input failure occurs before
any conversion such as an end-of-file occurs. If an error
or end-of-file occurs after conversion has begun, the num-
ber of conversions which were successfully completed is
returned.
In the above case, if the return value was 1, it would mean that you sucessfully scanned in one item, which would be what you want for the above code.

Quzah.