当前位置:网站首页>Count the number of words in a line of string and take it as the return value of the function
Count the number of words in a line of string and take it as the return value of the function
2022-06-26 16:44:00 【Muzi..】
#include<stdio.h>
#include<string.h>
#define N 80
int fun(char *s);
int main()
{
char line[N];
int num=0;
printf("enter a string:\n");
gets(line);
num=fun(line);
printf("the number of words is:%d\n\n",num);
}
int fun(char *s)
{
int i,j;
for(i=0;s[i]!='\0';i++)
if(s[i]!=' '&&(s[i+1]==' '||s[i+1]=='\0'))
j++;
return j;
}
边栏推荐
- 长安链交易防重之布谷鸟过滤器
- 最小二乘系统辨识课 中篇:递归最小二乘
- 【从删库到跑路】JDBC 完结篇(一天学完系列!!学完赶紧跑!)
- 构造函数和析构函数
- LeetCode Algorithm 24. Exchange the nodes in the linked list in pairs
- Scala Foundation (2): variables et types de données
- stm32h7b0替代h750程序导致单片机挂掉无法烧录程序问题
- Least squares system identification class II: recursive least squares
- 【从删库到跑路】MySQL基础 完结篇(入个门先跑路了。。)
- Calculate a=1, a2=1/1=a1
猜你喜欢

Research on natural transition dubbing processing scheme based on MATLAB

100+ data science interview questions and answers Summary - basic knowledge and data analysis

Science | 红树林中发现的巨型细菌挑战传统无核膜观念

【毕业季】致毕业生的一句话:天高任鸟飞,海阔凭鱼跃

1-12Vmware新增SSH功能

C语言 头哥习题答案截图
Scala 基础 (二):变量和数据类型

Pybullet robot simulation environment construction 5 Robot pose visualization

Natural language inference with attention and fine tuning Bert pytorch

我把它当副业月入3万多,新手月入过万的干货分享!
随机推荐
Scala Basics (II): variables and data types
Développer un opérateur basé sur kubebuilder (démarrer)
R language uses cor function to calculate the correlation matrix for correlation analysis, uses corrgram package to visualize the correlation matrix, reorders rows and columns using principal componen
STM32F103C8T6实现呼吸灯代码
【从删库到跑路】MySQL基础 完结篇(入个门先跑路了。。)
Redis Guide (8): principle and implementation of Qianfan Jingfa distributed lock
[force deduction question] two point search: 4 Find the median of two positive arrays
Cloud platform monitoring system based on stm32+ Huawei cloud IOT design
C language -- legal identifier and integer
Overall context of concurrent programming
Vibrating liquid quantity detecting device
Hyperf框架使用阿里云OSS上传失败
R329 (maix-ii-a (M2A) data summary
牛客编程题--必刷101之动态规划(一文彻底了解动态规划)
Develop operator based on kubebuilder (for getting started)
建立自己的网站(16)
基於Kubebuilder開發Operator(入門使用)
Solution for filtering by special string of microservice
Some instance methods of mono
JS tutorial - printing stickers / labels using the electronjs desktop application