I'm one of the many who encountered a problem with the getchar() function picking up the newline '\n' as an input on subsequent getchar() statements.
I googled and found the following solution such that the second getchar() doesn't get a newline as an input and it works.
However, I don't get how the while (getchar() != '\n'); eliminates any newlines such that the following getchar() doesn't capture the newline as an entry.Code:input = getchar(); while (getchar() != '\n'); input = getchar();
I tried searching for this on Google but I didn't find any answers(that I understand) regarding this matter. :/
Can anyone explain, please? Thanks! And please keep in mind I only started programming 4 weeks ago which means I'm like absolutely noobish.