I am trying to get the user to enter a integer to be later used in the program I want it to force user to enter an input until it is an integer. When I run this code it goes on an infinite loop like so:
Enter smallest operator: Enter smallest operator: Enter smallest operator: Enter smallest operator: Enter smallest operator: Enter smallest operator:..........
I think the issue is with the scanner but I am unsure as to how I should approach it.
    #include <stdio.h>
#include <ctype.h>
int main(int argc, const char * argv[]) {
    char operator;
    int largestOpperator, smallestOpperator;
    printf("Enter The Table Operator (+, -, *, /, %%, or R): ");
    scanf("%c",&operator);
    /*while(!(operator == '+' || operator == '-' || operator == '*' || operator == '/' ||operator == '%' || operator == 'R'))
    {
        printf("Enter Appropriate Table Operator (+, -, *, /, %%, or R): ");
        scanf(" %c",&operator); //requires space as a way to skip the enter when char is scanning!!
    }*/
    do{
        if(!isdigit(smallestOpperator))
            printf("Enter smallest operator: ");
        else{
            printf("Enter an actual number: ");
            scanf(" %d", &smallestOpperator);
        }
    }while(!isdigit(smallestOpperator));
    printf("Enter largest operator: ");
    scanf("%d", &largestOpperator);
    {
        printf("Enter a valid integer: ");
        scanf("%d", &largestOpperator);
    }
    return 0;
}
 
    