当前位置:网站首页>Count the number of words in the string c language
Count the number of words in the string c language
2022-07-07 08:57:00 【Please Sit Down】
Calculate formal parameters s The number of words contained in the indicated word string , Return... As a function value .
For the convenience of Statistics , Stipulate that each word is separated by a space .
Columns such as : Shape parameter s The string referred to is :This is a c language program., The return value of the function is 6.
#include <stdio.h>
int fun(char *s){
int n = 0, flag = 0;
while (*s != '\0'){
if (*s != ' ' && flag == 0){
n++;
flag = 1;
}
if (*s == ' ')
flag = 0;
s++;
}
return n;
}
int main(){
char str[81];
int n;
printf("Enter a line text:");
gets(str);
n = fun(str);
printf("There are %d words in this text.", n);
}边栏推荐
- Data analysis methodology and previous experience summary 2 [notes dry goods]
- 求有符号数的原码、反码和补码【C语言】
- 使用Typora编辑markdown上传CSDN时图片大小调整麻烦问题
- H3C VXLAN配置
- Interpolation lookup (two methods)
- Greenplum 6.x reinitialization
- How to add a mask of a target in a picture
- 串口实验——简单数据收发
- Newly found yii2 excel processing plug-in
- UnityShader入门精要个人总结--基础篇(一)
猜你喜欢
![Data analysis methodology and previous experience summary 2 [notes dry goods]](/img/e1/643e847a777e1effcbd39f8b009e2b.png)
Data analysis methodology and previous experience summary 2 [notes dry goods]

NCS Chengdu Xindian interview experience

Greenplum6.x常用语句
![[Yugong series] February 2022 U3D full stack class 006 unity toolbar](/img/2e/3a7d71a0b5a6aff294a0bd2f8515f8.jpg)
[Yugong series] February 2022 U3D full stack class 006 unity toolbar

Unityshader introduction essentials personal summary -- Basic chapter (I)

Markdown编辑器Editor.md插件的使用

oracle一次性说清楚,多种分隔符的一个字段拆分多行,再多行多列多种分隔符拆多行,最终处理超亿亿。。亿级别数据量

Quick sorting (detailed illustration of single way, double way, three way)

Category of IP address

The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
随机推荐
Isomorphic C language
Uniapp wechat applet monitoring network
Greenplum 6.x build_ Environment configuration
[Yugong series] February 2022 U3D full stack class 005 unity engine view
Panel display technology: LCD and OLED
最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
How to add a mask of a target in a picture
Sign and authenticate API interface or H5 interface
Speaking of a software entrepreneurship project, is there anyone willing to invest?
【踩坑】nacos注册一直连接localhost:8848,no available server
leetcode135. Distribute candy
MAC OSX php dyld: Library not loaded: /usr/local/xxxx. dylib
硬件大熊原创合集(2022/05更新)
年薪50w阿裏P8親自下場,教你如何從測試進階
Unityshader introduction essentials personal summary -- Basic chapter (I)
leetcode134. gas station
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
OpenGL三维图形绘制
【istio简介、架构、组件】
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂