Home > Backend Development > C#.Net Tutorial > Detailed explanation of strlen usage in C language

Detailed explanation of strlen usage in C language

hzc
Release: 2020-06-17 14:31:56
Original
17479 people have browsed it

Detailed explanation of strlen usage in C language

Detailed explanation of strlen usage in c language:

The function of strlen() function is to count the length of a given string.

Function prototype: unsigned int strlen(char *str);

Function: Count the number of characters in the string str, excluding '\0'

Return value: Return the number of characters

Example:

char *str1 = "abcdef";   // 定义一个字符指针
char str2[] = "abcdef";  // 定义一个字符数组
int len = strlen(str1);  // 统计str1字符的个数,结果为6
int len = strlen(str2);  // 统计str2字符的个数,结果为6
Copy after login

Recommended tutorial: "c"

The above is the detailed content of Detailed explanation of strlen usage in C language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template