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

这篇文章主要介绍了C语言实现统计字符串单词数,代码非常的简洁,有需要的小伙伴快来参考下。

字符串单词数.c

 #include #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); } 

以上所述就是本文的全部内容,希望大家能够喜欢。

以上就是C语言实现统计字符串单词数的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » C语言