当前位置:网站首页>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);
}边栏推荐
- Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
- 【ChaosBlade:节点 CPU 负载、节点网络延迟、节点网络丢包、节点域名访问异常】
- Markdown editor Use of MD plug-in
- 阿里p8推荐,测试覆盖率工具—Jacoco,实用性极佳
- Redis summary
- 2022-07-06 Unity核心9——3D动画
- Why choose cloud native database
- [wechat applet: cache operation]
- Enterprise manager cannot connect to the database instance
- 测试人一定要会的技能:selenium的三种等待方式解读,清晰明了
猜你喜欢

面试题:高速PCB一般布局、布线原则
![Upload an e-office V9 arbitrary file [vulnerability recurrence practice]](/img/e7/278193cbc2a2f562270f99634225bc.jpg)
Upload an e-office V9 arbitrary file [vulnerability recurrence practice]

Output all composite numbers between 6 and 1000

Digital triangle model acwing 1027 Grid access

最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼

Greenplum6.x常用语句

LeetCode 715. Range 模块

Interpolation lookup (two methods)

let const

Led analog and digital dimming
随机推荐
面试题:高速PCB一般布局、布线原则
Greenplum6.x搭建_安装
2022-07-06 Unity核心9——3D动画
Golang etcdv3 reports an error. The attribute in grpc does not exist
Sign and authenticate API interface or H5 interface
[step on the pit] Nacos registration has been connected to localhost:8848, no available server
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
Gson converts the entity class to JSON times declare multiple JSON fields named
Opencv converts 16 bit image data to 8 bits and 8 to 16
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
Calf problem
【Istio Network CRD VirtualService、Envoyfilter】
【ChaosBlade:节点 CPU 负载、节点网络延迟、节点网络丢包、节点域名访问异常】
Esp32-ulp coprocessor low power mode RTC GPIO interrupt wake up
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
MySQL partition explanation and operation statement
Test pits - what test points should be paid attention to when adding fields to existing interfaces (or database tables)?
指针进阶,字符串函数
Mock. JS usage details
Platformization, a fulcrum of strong chain complementing chain