sostituisci

getchar()

con

while(getchar() != '\n') ;

p.s. non ho provato... ma se la memoria
non mi inganna dovrebbe essere giusto.