# 比如 strlen 函数的使用
计算字符串长度,使用`strlen`函数,那么可以在命令行执行`man strlen`得到类似的如下结果
> 我是在mac上操作的
```shell
STRLEN(3) BSD Library Functions Manual STRLEN(3)
NAME
strlen, strnlen -- find length of string
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <string.h>
size_t
strlen(const char *s);
size_t
strnlen(const char *s, size_t maxlen);
DESCRIPTION
The strlen() function computes the length of the string s. The strnlen()
function attempts to compute the length of s, but never scans beyond the
first maxlen bytes of s.
```
需要引用`string.h`的头文件
# 编码
```c
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
char *p = "11111";
printf("%lu\n", strlen(p));
return 0;
}
```