# How to find the length of a string in C

> Learn how to find the length of a string in C using the strlen() function from the string.h standard library, which returns the length as an integer.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-02-08 | Topics: [C](https://flaviocopes.com/tags/clang/) | Canonical: https://flaviocopes.com/c-string-length/

Use the `strlen()` function provided by the [C](https://flaviocopes.com/c-introduction/) standard library `string.h` header file.

```c
char name[7] = "Flavio";
strlen(name);
```

This function will return the length of a string as an integer value.

Working example:

```c
#include <string.h>
#include <stdio.h>

int main(void) {
  char name[7] = "Flavio";
  int length = strlen(name);
  printf("Name length: %u", length);
}
```
