# 比如 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;
}
```