[#bsl-basic_string-01d-copy]
= xref:bsl.adoc[bsl]::xref:bsl/basic_string-01d.adoc[basic&lowbar;string&lt;char8&lowbar;t&gt;]::copy
:relfileprefix: ../../
:mrdocs:

Copy from this string, starting from the optionally specified `position`, the specified `numChars` or `length() &hyphen; position` characters, whichever is smaller, into the specified `characterString` buffer, and return the number of characters copied&period; If `position` is not specified, 0 is used&period; Throw `out&lowbar;of&lowbar;range` if `position &gt; length()`&period; The behavior is undefined unless `characterString` is at least `numChars` long&period; Note that the output `characterString` is _not_ null&hyphen;terminated&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type]
copy(
    char8&lowbar;t* characterString,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] numChars,
    xref:bsl/basic_string-01d/size_type.adoc[size&lowbar;type] position = 0) const;
----


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