Constructors That Use Part of a C-Style String
Constructors that use part of a C-style string let you initialize a string
object from part of a C-style string; more generally, they let you initialize a charT
specialization from part of an array of charT
values:
basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
This constructor copies to the constructed object a total of n
characters from the array pointed to by s
. Note that it doesn’t stop copying if s
has fewer characters than n
. If n
exceeds the length of s
, the constructor interprets the contents of memory following the string as if they held data of type charT
.
This constructor requires that s
is not a null pointer and that n < npos
. (Recall that npos
is a static ...
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.