I've been learning C for a while now and I've run into a problem with asking the user for input that has to meet some requirements. What I want to happen is when the input is the wrong ex. The input is not a number but a character, I want it to loop until the data is correct. My code:
#include <stdio.h>
int main() {
    int c;
    int number;
    printf("Insert your number: ");
    while (scanf_s("%d", &number) != 1 || getchar() != "\n" || number <= 0) {
        printf("Wrong input. Insert again: ");
        while ((c = getchar()) != '\n' && c != EOF);
    }
    printf("Your number is %d.", number);
    printf("\n\nEnd of the program\n\n");
    return 0;
}
Now the program reads all the input as incorrect and is stuck in an infinite loop. Any suggestions?
