当前位置:网站首页>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;
}
边栏推荐
- R语言--readr包读写数据
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
- DVC use case (VI): Data Registry
- Global and Chinese market of ice water machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Clockwise rotation method of event arrangement -- PHP implementation
- . Does net 4 have a built-in JSON serializer / deserializer- Does . NET 4 have a built-in JSON serializer/deserializer?
- 0x15 string
- Alibaba cloud server connection intranet operation
- In 2022, financial products are not guaranteed?
- How to use "bottom logic" to see the cards in the world?
猜你喜欢
Azure solution: how can third-party tools call azure blob storage to store data?
Paper notes ACL 2020 improving event detection via open domain trigger knowledge
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 5
Exness: positive I win, negative you lose
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
Star leap plan | new projects are continuously being recruited! MSR Asia MSR Redmond joint research program invites you to apply!
Detailed explanation of NPM installation and caching mechanism
It's hard to hear C language? Why don't you take a look at this (V) pointer
Games101 Lesson 8 shading 2 Notes
Entitas learning [3] multi context system
随机推荐
01. Basics - MySQL overview
Source code analysis of the implementation mechanism of multisets in guava class library
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
Decrypt the advantages of low code and unlock efficient application development
Possible to restore a backup of SQL Server 2014 on SQL Server 2012?
The detailed installation process of Ninja security penetration system (Ninjitsu OS V3). Both old and new VM versions can be installed through personal testing, with download sources
ASP. Net razor – introduction to VB loops and arrays
Alibaba cloud server connection intranet operation
DDS-YYDS
Paper notes ACL 2020 improving event detection via open domain trigger knowledge
OSI seven layer model & unit
C language compilation process
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
Anti clockwise rotation method of event arrangement -- PHP implementation
C language memory layout
MySQL advanced (Advanced) SQL statement
nn. Exploration and experiment of batchnorm2d principle
[ES6] template string: `string`, a new symbol in es2015
Global and Chinese market of dental elevators 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for environmental disinfection robots 2022-2028: Research Report on technology, participants, trends, market size and share