Can someone please explain to me in laymanz termz what'z going on with this snippet of code? I understand it'z a function used to get the first character then discard the remaining input but i am confused with the last while loop. When i googled it i found very complicated explanationz which went way over my head. There was one explanation that kind of made sense but it was an assembly code explanation dealing with the input being on the stack in memory and then my pea brain went numb. 😋
Code:
int get_First(void)
{
int ch, garbage;
do
{
ch = getchar();
}while(isspace(ch));
while((garbage = getchar()) != '\n' && garbage != EOF)
;
return ch;
}