Q:

get a specific range of floats from input

So I´m taking Harvard´s CS50 and this could benefit people who take the coure and are stuck with this issue.
I´m making a program called Resize, where we take 3 command line arguments, the first one is is 'f'. Exact quote:

the first (f) must be a floating-point value in (0.0, 100.0].

The question is: how to set a range of accepted values from a command-line argument.
I should use sscan() and atof() functions to do that.

A:

There is no way to restrict the command line arguments because it is entirely decided by the user of the command. What you can do is to get the argument and check it against your requirement. In your case, take the argument, and then convert it to a double value and check if it is in the desired range.
if (argc != 4) {
     puts("not enough argument");
     exit(1);
}
char *strf = argv[1];
char *end = NULL;
double f = strtod(strf, &end);
if (end == strf || *end != '\0') {
    puts("not a valid floating point value");
    exit(1);
}
if (errno == ERANGE) {
    puts("value out of range");
    exit(1);
}
if (f <= 0.0 || f > 100.0) {
    puts("value not in required range");
    exit(2);
}
// ... do other work with f

