[#BloombergLP-bdlb-String-strnlen]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/String.adoc[String]::strnlen
:relfileprefix: ../../../
:mrdocs:

Return the length of `string`, capped at `maximumLength`&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
strnlen(
    char const* string,
    int maximumLength);
----

== Description

Return the minimum of the length of the specified `string` and the specified `maximumLength`&period; If `maximumLength` is 0, `string` may be null and 0 is returned&period; The behavior is undefined unless `0 &lt;&equals; maximumLength`&period;

== Return Value

`min(strlen(string), maximumLength)`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *string*
| null&hyphen;terminated string to measure
| *maximumLength*
| upper bound on the returned length
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
