Ho risolto inserendo questa funzione:
void clear1 (void){
while ( getchar() != '\n' );
}