while( (b = getchar()) != EOF)
换成这个应该就好了
#include<stdio.h> #include<conio.h> main() { char ch; ch=EOF; printf("EOF=%d\n",ch); ch=getchar(); /*在这里输入【Ctrl+Z】*/ printf("When I Use getchar()...\n"); printf("[Ctrl+Z]=%c=%d\n",ch,ch); if(ch==EOF) printf("[Ctrl+Z]=EOF\n"); else printf("[Ctrl+Z]!=EOF\n"); ch=getch(); /*在这里输入【Ctrl+Z】*/ printf("When I Use getch()...\n"); printf("[Ctrl+Z]=%c=%d\n",ch,ch); if(ch==EOF) printf("[Ctrl+Z]=EOF\n"); else printf("[Ctrl+Z]!=EOF\n"); }