当前位置:网站首页>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);
}
边栏推荐
- Markdown editor Use of MD plug-in
- 对API接口或H5接口做签名认证
- selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
- Quick sorting (detailed illustration of single way, double way, three way)
- OpenGL三维图形绘制
- Upload an e-office V9 arbitrary file [vulnerability recurrence practice]
- 年薪50w阿裏P8親自下場,教你如何從測試進階
- 个人力扣题目分类记录
- let const
- Opencv converts 16 bit image data to 8 bits and 8 to 16
猜你喜欢
Category of IP address
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
数字三角形模型 AcWing 1027. 方格取数
Digital triangle model acwing 1027 Grid access
外部中断实现按键实验
leetcode134. gas station
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
Unityshader introduction essentials personal summary -- Basic chapter (I)
xray的简单使用
Goldbach conjecture C language
随机推荐
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
模拟卷Leetcode【普通】1705. 吃苹果的最大数目
Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
阿里p8手把手教你,自动化测试应该如何实现多线程?赶紧码住
Sign and authenticate API interface or H5 interface
Required String parameter ‘XXX‘ is not present
C language for calculating the product of two matrices
Upload an e-office V9 arbitrary file [vulnerability recurrence practice]
平台化,强链补链的一个支点
OpenGL frame buffer
Alibaba P8 teaches you how to realize multithreading in automated testing? Hurry up and stop
模拟卷Leetcode【普通】1706. 球会落何处
Three series of BOM elements
The longest ascending subsequence model acwing 1017 Strange thief Kidd's glider
leetcode135. Distribute candy
Simulation volume leetcode [general] 1567 Length of the longest subarray whose product is a positive number
Calf problem
Personal deduction topic classification record
2022-06-30 Unity核心8——模型导入