C - strlen()
C strlen() function - Get length of fixed size string
The strlen() function is used to get the length of a string excluding the ending null character.
Syntax:
size_t strlen(const char *str)
Parameters:
Name | Description | Required /Optional |
---|---|---|
str | Null-terminated string. | Required |
Return value from strlen()
- The strlen() function returns the length of str.
- No return value shall be reserved to indicate an error.
Example: strlen() function
#include<stdio.h>
#include<string.h>
int main()
{
char name[20]="w3resource.com";
int length;
length = strlen(name);
printf("Length of %s = %d\n",name,length);
return 0;
}
Output:
Length of w3resource.com = 14
C Programming Code Editor:
Previous C Programming: C strerror()
Next C Programming: C strpbrk()
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/c-programming/string/c-strlen.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics