To enable complete validation, you need to read things as a string, then convert.


char buff[BUFSIZ];
while ( fgets( buff, BUFSIZ, stdin ) != NULL ) {
if ( sscanf(buff,"%d",&year) == 1 &&...