[Solved] C reading input in while loop [closed]
Well, this piece of code int c; while ((c = getchar()) != EOF && c != ‘\n’); is used to clear the buffer, as mentioned in @napnac’s answer. It is mainly used instead of fflush (stdin);, which is UB. But note that this is successful only if the input buffer happens to contain data ending … Read more