当前位置:网站首页>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;
}
边栏推荐
- Data communication and network: ch13 Ethernet
- LVS load balancing cluster deployment - Dr direct routing mode
- Review of week 278 of leetcode II
- Possible to restore a backup of SQL Server 2014 on SQL Server 2012?
- The most robust financial products in 2022
- [notes] in depth explanation of assets, resources and assetbundles
- Netgear switch basic configuration command set
- Cadence physical library lef file syntax learning [continuous update]
- How do std:: function and function pointer assign values to each other
- Btrace tells you how to debug online without restarting the JVM
猜你喜欢
Realize cross tenant Vnet connection through azure virtual Wan
It's hard to hear C language? Why don't you take a look at this (V) pointer
How to create a new virtual machine
Ternsort model integration summary
Reptile learning winter vacation series (2)
When synchronized encounters this thing, there is a big hole, pay attention!
netstat
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
LVS load balancing cluster deployment - Dr direct routing mode
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
随机推荐
Global and Chinese markets for environmental disinfection robots 2022-2028: Research Report on technology, participants, trends, market size and share
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
C语言:求字符串的长度
A few words explain redis cache penetration, breakdown, avalanche, and redis sentinel
DVC use case (VI): Data Registry
template<typename MAP, typename LIST, typename First, typename ... Keytypes > recursive call with indefinite parameters - beauty of Pan China
Guava ImmutableSet. Builder source code analysis, shift original code, complement code, reverse code review
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
Global and Chinese markets for soluble suture 2022-2028: Research Report on technology, participants, trends, market size and share
Classification and application of AI chips
Anti clockwise rotation method of event arrangement -- PHP implementation
Servlet learning notes
[ES6] template string: `string`, a new symbol in es2015
Translation D29 (with AC code POJ 27:mode of sequence)
Iframe to only show a certain part of the page
JD home programmers delete databases and run away. Talk about binlog, the killer of MySQL data backup
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
How to use "bottom logic" to see the cards in the world?
Pat 1059 prime factors (25 points) prime table
Communication tutorial | overview of the first, second and third generation can bus