int main()
{
int c,nl,nt,Blanks;
nl = 0;
nt = 0;
Blanks = 0;
while ((c= getchar()) != '5'){
if (c ='\n')
nl++;
if(c='\t')
nt++;
if(c = 's')
Blanks ++;
}
printf("No of lines is %d \n No of tabs %d \n and no of blanks %d \n",nl,nt,Blanks);
return 0;
输出:
No of lines is 12
No of tabs 12
and no of blanks 12
RUN SUCCESSFUL (total time: 5s)
输出是输入的任何字符的编号,根本不区分它们。此外,当我使用 EOF 使循环在到达文件末尾时停止时,循环并没有停止,程序继续运行。