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

Copy `srcString` into `dstString`, padding to `dstLength` if needed&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
void
toFixedLength(
    char* dstString,
    int dstLength,
    char const* srcString,
    int srcLength,
    char padChar = &apos; &apos;);
----

== Description

Copy into the specified `dstString` at most the specified leading `dstLength` characters from the specified `srcString` having the specified `srcLength`&period; If `srcLength &lt; dstLength`, after `srcString` is copied to `dstString` repeatedly append to `dstString` the optionally specified `padChar` until the total number of characters written to `dstString` is `dstLength`&period; If `padChar` is not specified the space (` `) character is appended&period; The behavior is undefined unless `0 &lt;&equals; dstLength` and `0 &lt;&equals; srcLength`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *dstString*
| destination buffer
| *dstLength*
| number of characters to write to `dstString`
| *srcString*
| source string
| *srcLength*
| length of `srcString`
| *padChar*
| padding character when `srcLength &lt; dstLength`
|===


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