I'm not asking for a solution but rather for an explanation.
I'd like to understand why this enters an infinite loop (printing "Escolha um ano" non-stop) if the input is invalid.
while(error)
{
puts("Escolha um ano:");
if(scanf(" %d", &ano)!= 1)
{
puts("Escolheu mal o ano. Tente de novo");
}
else error = 0;
}