n1 and n2 are two ints ...
If the input is legal but the entered n1 or n2 or the calculated output value is out of the range of an unsigned long int value, then the corresponding output should be
out of range
how would this be possible with scanf?
n1 and n2 are two ints ...
If the input is legal but the entered n1 or n2 or the calculated output value is out of the range of an unsigned long int value, then the corresponding output should be
out of range
how would this be possible with scanf?
I don't think you can tell with scanf.
If you want better validation, read in the input as a string (using fgets for example), and use strtol to convert it to a long. You can then check for range errors.
Last edited by cwr; 02-20-2006 at 12:08 AM.
I didnt quite get that ... would you please at least post some code...
Read the handy dandy FAQ on getting a number from the user. Use your handy dandy browser to point yourself at a search engine, type in strtol, and surprise yourself that you can find the answer on your own.
Quzah.
Hope is the first step on the road to disappointment.