原创 判断并输出输入的字符串中空格、回车、Tab和总字符串个数

2009-12-30 14:32 2778 4 4 分类: MCU/ 嵌入式

#include<stdio.h>
main()
{
 long table="0",enter=0,total=0,other=0,space=0;
 char c;
   while( (c=getchar())!=EOF)
   {  
    if(c=='\n')
    ++enter;
    else if (c=='\t')
    ++table;
    else if (c==' ')
    ++space;
    else
    ++other;
    ++total;
   }
   printf("\nthe enter is %d\n",enter);
   printf("the table is %d\n",table);
   printf("the space is %d\n",space);
   printf("the other is %d\n",other);
   printf("the total is %d\n",total);
}


PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
4
关闭 站长推荐上一条 /2 下一条