练习4-8 假定最多只压回一个字符。请相应地修改getch和ungetch这两个函数。
#include <stdio.h>
#include "calc.h"
int buf = EOF;
int getch(void)
{
int temp = buf;
buf = EOF;
return (temp != EOF) ? temp : getchar();
}
void ungetch(int c)
{
buf = c;
return;
}
练习4-8 假定最多只压回一个字符。请相应地修改getch和ungetch这两个函数。
#include <stdio.h>
#include "calc.h"
int buf = EOF;
int getch(void)
{
int temp = buf;
buf = EOF;
return (temp != EOF) ? temp : getchar();
}
void ungetch(int c)
{
buf = c;
return;
}