Properly read integer in a range in C
regarding: 

if (fgets(line, sizeof(line), stdin) != line || feof(stdin))  


This is unnecessary messy.  Suggest: 

if( fgets( line, sizeof( line ), stdin )


If any error occurs, the returned value is NULL so the body of the if() will not be entered.

regarding:

if (fgets(line, sizeof(line), stdin) != line || feof(stdin)) {
            exit(EXIT_FAILURE);
            break;


the break; will never be executed because the call to exit() will have already exited the program.

regarding:

while(!feof(stdin));


please read: while(!feof()) is always wrong

regarding:

    return n;
} while(true);


The return is always executed, so this loop will never iterate, looking for a valid input.

regarding:

char *cursor = line;
        while ((*cursor == ' ' || *cursor == '\t') &amp;&amp; *cursor != '\0') {
            cursor++;
        }        
        if (*cursor == '\n') {
            return n;
        }


This while() code block will iterate to the end of the array line[], most of the time.  the result will be no number will be extracted.  Suggest, starting at line[0] to check for isdigit( line[i] ) and if true, then extract the number, perhaps using something like: strtol()