Input buffer

while ((c = getchar()) != ‘\n’ && c != EOF) { }

Can anyone explain me how this works to clear the input buffer? With an example?

You can refer this link