不是说ungetc(ch, stdin)中ch如其没有读出来不是放不进去新的字符吗

不是说ungetc(ch, stdin)中ch如果没有读出来不是放不进去新的字符吗?
下面是个练习ungetc()小程序:

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int main(void)
{

char ch, ch1, ch2;
scanf("%c", &ch);
ch1 = getchar();
ungetc(ch, stdin);
ungetc(ch1, stdin);
ch2 = getchar();
printf("%c\n", ch2);

return 0;
}


比如我在黑窗口中输入whale,我想应该是ch = w;ch1 =h;了,再把ch放回缓冲区中,又把ch1放回缓冲区中,因为ch放回去后没有及时读取,应该ch1是放不回去的,那么应该ch2 = w才是,因为ch2要到缓冲区读取数据,那这个数据应该是w.但是结果是ch2 = h;为什么?

------解决方案--------------------

int
main (int argc, char **argv)
{
        ungetc ('\n', stdin);
        ungetc ('c', stdin);
        ungetc ('b', stdin);
        ungetc ('a', stdin);

        printf ("%c", getc(stdin));
        printf ("%c", getc(stdin));
        printf ("%c", getc(stdin));
        printf ("%c", getc(stdin));
        return 0;
}

把这程序看懂了, 你就明白了
------解决方案--------------------
ungetc(ch1, stdin);
ch2 = getchar();

所以实际上ch2=ch1,为字符h

引用:
下面是个练习ungetc()小程序:

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int main(void)
{

char ch, ch1, ch2;
scanf("%c", &ch);
ch1 = getchar();
ungetc(ch, stdin);
ungetc(ch1, stdin);
ch2 = getchar();
printf("%c\n", ch2);

return 0;
}


比如我在黑窗口中输入whale,我想应该是ch = w;ch1 =h;了,再把ch放回缓冲区中,又把ch1放回缓冲区中,因为ch放回去后没有及时读取,应该ch1是放不回去的,那么应该ch2 = w才是,因为ch2要到缓冲区读取数据,那这个数据应该是w.但是结果是ch2 = h;为什么?