源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

C语言实现统计字符串单词数

  • 时间:2022-02-02 12:21 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:C语言实现统计字符串单词数
字符串单词数.c
#include<stdio.h>
#define BUFFERSIZE 1024
 
int main()
{
 char string[BUFFERSIZE];
 int i,count=0,word=0;
 char c;
 gets(string) ;
 for(i=0;(c=string[i])!='\0';i++)
 {
  if(c==' ')
   word=0;
  else if(word==0)
  {
   word=1;
   count++;
  }
 }
 printf("%d \n",count);
}

以上所述就是本文的全部内容,希望大家能够喜欢。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部