I've run into a problem that, oddly enough, I can't solve. It is necessary for the user to prohibit the input of letters and any other characters that are not related to numbers. That is, the usual check whether it is a number or not a number, and in case of incorrect data entry, return the user back to the input. Who is not difficult, please tell me how to implement in my program. Here is a snippet of the program.
int main() {
    int n, m;
    printf("Enter the number of planned measurements for the variance count and math. expectations taking into account the statistical outlier: ");
    scanf_s("%d", &n);
    if (!isdigit(n)) {
         printf("\nYou can only enter letters!\n");
         printf("Enter the data correctly: ");
         scanf_s("%d", &n);
    }
    printf("Enter the number of planned measurements for the variance count and math. expectations: ");
    scanf_s("%d", &m);
    printf("===================================================\n");
    printf("Enter your measurements for the variance count and math. expectations taking into account the statistical outlier: ");
}
Used isdigit() but didn't work.
if (!isdigit(n)) {
     printf("\nYou can only enter letters!\n");
     printf("Enter the data correctly: ");
     scanf_s("%d", &n);
}
and
while (int n = (int)_getch()){
    if (isdigit(n)){
        cout << n;
    }
}