Take a look a this piece of code, which is supposed to get the date of birth of a user, in the form of three variables belonging to a struct.
printf("Insert date of birth in this format: dd/mm/yyyy\n");
scanf("%d/%d/%d", &user.bDay, &user.bMonth, &user.bYear);
while(isalpha(user.bDay)==1||isalpha(user.bMonth)==1||isalpha(user.bYear)==1){
puts("Invalid input");
scanf("%d/%d/%d", &user.bDay, &user.bMonth, &user.bYear);
}
What if the user types characters? Something like 1q/02/199i? I wanted to make the program print an error message and simply asking the user to insert his date of birth again. I tried using isalpha function, as you can see in the code, but it doesn't work, the program crashes and prints "Invalis input" infinite times. How can I make the user insert only integers?