People usually mention
while( getchar() != '\n' )
when it comes to clearing the input buffer or overflow.
fgetc
or getc
also work. For example:
while( fgetc(stdin) != '\n' )
and
while( getc(stdin) != '\n' )
Is there any particular reason why people always use getchar
?
Is there any disadvantage to using fgetc
or getc
?