EOF looks like it should already be handled correctly. getch() will return it to getop() which will return it here:
It wont cause EOF has allready been getchared and nowhere stored! Next getch call will try reading a char after EOF signal!
In this case only getop() needs to change to pushback c irrespective of its value.
You mean deleting the if(c!= EOF).
But then ill have to edit getch(). I was thinking about something like this:
Code:
#include "calc.h"
int buf = EOF;
int getch()
{
int temp;
if(buf == 1) return EOF;
if(buf == EOF)
{
temp = getchar();
}
else
{
temp = buf;
buf = EOF;
}
return temp;
}
void ungetch(int c) //stores the temp char
{
if(c == EOF)
{
buf = 1;
return;
}
buf = c;
}