当前位置:网站首页>C language: find the length of string
C language: find the length of string
2022-07-04 12:35:00 【Nianchi ichthyology programming】
problem :
Write a function , Find the length of a string , stay main Input string in function , And output its length .
Code
#include <stdio.h>
#include <stdlib.h>
int length(char *s)
{
int i = 0;
while(*s != '\0'){
i++;
s++;
}
return 1;
}
int main()
{
int len;
char str[20];
printf(" Please enter the string :\n");
scanf("%s",str);
len = length(str);
printf(" String has %d Characters .\n",len);
return 0;
}
边栏推荐
- Global and Chinese market of dental elevators 2022-2028: Research Report on technology, participants, trends, market size and share
- asp. Core is compatible with both JWT authentication and cookies authentication
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
- MySQL advanced review
- In 2022, financial products are not guaranteed?
- What if the chat record is gone? How to restore wechat chat records on Apple Mobile
- Wechat video Number launches "creator traffic package"
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
- Clockwise rotation method of event arrangement -- PHP implementation
- ASP. Net razor – introduction to VB loops and arrays
猜你喜欢
Lecture 9
Force buckle 142 Circular linked list II
Awk getting started to proficient series - awk quick start
Azure solution: how can third-party tools call azure blob storage to store data?
Games101 Lesson 8 shading 2 Notes
nn. Exploration and experiment of batchnorm2d principle
The database connection code determines whether the account password is correct, but the correct account password always jumps to the failure page with wrong account password
2022, 6G is heating up
What if the chat record is gone? How to restore wechat chat records on Apple Mobile
R语言--readr包读写数据
随机推荐
C语言:求100-999是7的倍数的回文数
A few words explain redis cache penetration, breakdown, avalanche, and redis sentinel
【数据聚类】第四章第一节3:DBSCAN性能分析、优缺点和参数选择方法
Force buckle 142 Circular linked list II
Data communication and network: ch13 Ethernet
vim 出现 Another program may be editing the same file. If this is the case 的解决方法
SAP ui5 date type sap ui. model. type. Analysis of the display format of date
Entity framework calls Max on null on records - Entity Framework calling Max on null on records
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
R语言--readr包读写数据
[notes] streamingassets
Haproxy cluster
How to create a new virtual machine
Netgear switch basic configuration command set
Hongke case study on storm impact in coastal areas of North Carolina using lidar
Global and Chinese markets for environmental disinfection robots 2022-2028: Research Report on technology, participants, trends, market size and share
C language compilation process
mm_ Cognition of struct structure
CSDN documentation specification
Bottom Logic -- Mind Map