<cstring>
The <cstring>
header is for the C++ version of the C standard <string.h>
header, which declares
string-handling functions.
The functions in this section fall into two categories, identified by the first three letters of the function name:
mem
. . .The
mem
functions operate on arbitrary chunks of memory, treating the memory as arrays ofunsigned
char
. The caller must specify the size of each memory chunk.str
. . .The
str
functions operate on null-terminated character arrays. Even though the function parameters are declared as typechar
, they are always interpreted asunsigned
char
when comparing two characters.
See also <cwchar>
for
wide character string functions.
Note
Instead of using C-style, null-terminated character arrays, C++
code should use the string
and
wstring
classes that are declared
in the <string>
header. C++
strings offer high performance, more flexibility, more safety, and
greater ease of use. The char_traits
class template in <string>
also provides member
functions for working with narrow and wide character arrays.
Get C++ In a Nutshell 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.