当前位置:网站首页>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;
}
边栏推荐
- Entity framework calls Max on null on records - Entity Framework calling Max on null on records
- How to disable debug messages on sockjs stomp - how to disable debug messages on sockjs Stomp
- netstat
- Detailed explanation of NPM installation and caching mechanism
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
- Force buckle 142 Circular linked list II
- Global and Chinese market for naval vessel maintenance 2022-2028: Research Report on technology, participants, trends, market size and share
- Data communication and network: ch13 Ethernet
- C语言:求字符串的长度
- Pat 1059 prime factors (25 points) prime table
猜你喜欢

Realize cross tenant Vnet connection through azure virtual Wan

Clion configuration of opencv
![Entitas learning [3] multi context system](/img/f9/a3ce86ff2121dd1043305b7e834cc5.jpg)
Entitas learning [3] multi context system

Star leap plan | new projects are continuously being recruited! MSR Asia MSR Redmond joint research program invites you to apply!

Flet教程之 按钮控件 ElevatedButton入门(教程含源码)

Decrypt the advantages of low code and unlock efficient application development

Exness: positive I win, negative you lose

vim 出现 Another program may be editing the same file. If this is the case 的解决方法

netstat

Error: Failed to download metadata for repo ‘AppStream‘: Cannot download repomd. XML solution
随机推荐
R语言--readr包读写数据
(August 10, 2021) web crawler learning - Chinese University ranking directed crawler
Haproxy cluster
Uva536 binary tree reconstruction tree recovery
OSI seven layer model & unit
asp. Core is compatible with both JWT authentication and cookies authentication
Entitas learning [3] multi context system
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15
01. Basics - MySQL overview
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
C language memory layout
vim 出现 Another program may be editing the same file. If this is the case 的解决方法
Enter the smart Park, and change begins here
Ml and NLP are still developing rapidly in 2021. Deepmind scientists recently summarized 15 bright research directions in the past year. Come and see which direction is suitable for your new pit
SAP ui5 date type sap ui. model. type. Analysis of the display format of date
'using an alias column in the where clause in PostgreSQL' - using an alias column in the where clause in PostgreSQL
记一次 Showing Recent Errors Only Command /bin/sh failed with exit code 1 问题
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
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
Lecture 9