#include <stdio.h>
int main()
{
int count = 0;
printf("请输入英文:");
while(getchar() != '\n')
{
count = count + 1;
}
printf("你一共输入了%d个字符。", count);
return 0;
}
getchar()有一个int型的返回值。当程序调用getchar()时,程序就等着用户按键,用户输入的字符被存放在键盘缓冲区中,直到用户按回车为止(回车字符也放在缓冲区中),当用户键入回车之后,getchar()才开始从stdio流中