Just a little confusion, I hope someone can clarify - this question asks: "Our getch and ungetch canβt cope with properly configured EOFs. Decide what their properties should be if EOF is dropped and then your project is implemented."
With the code as it is, EOF is thrown back, returned using getch (), which causes a loop such as:
while ((c = getch()) != EOF) putchar(c);
to complete when it is encountered from the buffer. I do not see how this behavior is wrong. Of course, since the EOF will theoretically (mostly) ever occur once if it is pushed back and then read from the buffer this way, does it really matter? I hope someone can clarify the purpose of this question for me - I understand that most solutions include ungetch () programming to ignore EOF, I just don't see the point.
I am sure that there is one, since Dennis Ritchie and Brian Kernighan are much brighter than me - I just hoped that someone could point it out. Thanks: -)
Regards, Phil
source share