当前位置:网站首页>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);
}
边栏推荐
- Skills that testers must know: Selenium's three waiting ways are interpreted clearly
- Routing information protocol rip
- The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
- Several common database connection methods
- [Yugong series] February 2022 U3D full stack class 005 unity engine view
- Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
- ChaosBlade:混沌工程简介(一)
- Greenplum 6.x build_ Environment configuration
- 2022-07-06 Unity核心9——3D动画
- Troublesome problem of image resizing when using typora to edit markdown to upload CSDN
猜你喜欢
xray的简单使用
FPGA knowledge accumulation [6]
2022-07-06 unity core 9 - 3D animation
Unityshader introduction essentials personal summary -- Basic chapter (I)
Routing information protocol rip
[Yugong series] February 2022 U3D full stack class 006 unity toolbar
Oracle makes it clear at one time that a field with multiple separators will be split into multiple rows, and then multiple rows and columns. Multiple separators will be split into multiple rows, and
Data analysis methodology and previous experience summary 2 [notes dry goods]
UnityShader入门精要个人总结--基础篇(一)
Three series of BOM elements
随机推荐
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
Common operating commands of Linux
ncs成都新电面试经验
OpenGL帧缓冲
数字三角形模型 AcWing 275. 传纸条
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
Lenovo hybrid cloud Lenovo xcloud: 4 major product lines +it service portal
Calculation s=1+12+123+1234+12345 C language
About using CDN based on Kangle and EP panel
阿里p8推荐,测试覆盖率工具—Jacoco,实用性极佳
阿里p8手把手教你,自动化测试应该如何实现多线程?赶紧码住
Golang etcdv3 reports an error. The attribute in grpc does not exist
idea里使用module项目的一个bug
模拟卷Leetcode【普通】1706. 球会落何处
[Nanjing University] - [software analysis] course learning notes (I) -introduction
MySQL主从延迟的解决方案
9c09730c0eea36d495c3ff6efe3708d8
Greenplum 6.x version change record common manual
PPT模板、素材下载网站(纯干货,建议收藏)
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot