Strlen
strlen is a C library function that returns the number of characters in a null-terminated string before its terminating null character.
Modern C, Third Edition
strlen is a C standard-library function that returns the number of characters before the terminating zero in a string.
- How it is used
- Measures a zero-terminated string before copying, comparing, or sizing storage for it.
- How deep it goes
- Defines the first-zero rule, array-size distinction, termination requirement, and size_t result without detailing implementation internals.
- Examples
- Uses argv[0] to size a destination array before copying and comparing the program name.
- What you can do after
- Apply strlen through the C string library while preserving zero termination and allocating room for the terminator.
Modern C
strlen is a C standard library function that returns the number of characters before the null terminator of a string.
- How it is used
- Uses strlen to measure a null-terminated C string before allocating or copying storage.
- How deep it goes
- Defines the count and demonstrates allocation and copying, while deferring implementation internals.
- Examples
- Demonstrates measuring argv[0], sizing a variable-length array, copying characters, and adding the terminating 0.
- What you can do after
- Apply via the C standard library to measure valid strings and size storage for subsequent operations.
Related concepts
- stringuses · A string is a programming-language value representing an ordered sequence of characters or character units as text.
- memchralternative to · memchr is a C standard-library function that searches a specified memory region for the first byte having a given value.
- string.hconfigured by · string.h is the C standard library header declaring functions for manipulating strings, character arrays, and related memory sequences.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

