Null-terminated byte strings - cppreference.com

From cppreference.com

A null-terminated byte string (NTBS) is a possibly empty sequence of nonzero bytes followed by a byte with value zero (the terminating null character). Each byte in a byte string encodes one character of some character set. For example, the character array {'\x63','\x61','\x74','\0'} is an NTBS holding the string "cat" in ASCII encoding.

Functions

Character classification Defined in header

<cctype>

isalnum

checks if a character is alphanumeric
(function)

[edit]

isalpha

checks if a character is alphabetic
(function)

[edit]

islower

checks if a character is lowercase
(function)

[edit]

isupper

checks if a character is an uppercase character
(function)

[edit]

isdigit

checks if a character is a digit
(function)

[edit]

isxdigit

checks if a character is a hexadecimal character
(function)

[edit]

iscntrl

checks if a character is a control character
(function)

[edit]

isgraph

checks if a character is a graphical character
(function)

[edit]

isspace

checks if a character is a space character
(function)

[edit]

isblank

(C++11)

checks if a character is a blank character
(function)

[edit]

isprint

checks if a character is a printing character
(function)

[edit]

ispunct

checks if a character is a punctuation character
(function)

[edit]

Character manipulation

tolower

converts a character to lowercase
(function)

[edit]

toupper

converts a character to uppercase
(function)

[edit]

ASCII values characters

iscntrl

iswcntrl

isprint

iswprint

isspace

iswspace

isblank

iswblank

isgraph

iswgraph

ispunct

iswpunct

isalnum

iswalnum

isalpha

iswalpha

isupper

iswupper

islower

iswlower

isdigit

iswdigit

isxdigit

iswxdigit

decimal hexadecimal octal 0–8 \x0–\x8\0–\10control codes (NUL, etc.) ≠0000000000009 \x9\11tab (\t) ≠00≠0≠00000000010–13 \xA–\xD\12–\15whitespaces (\n, \v, \f, \r) ≠00≠000000000014–31 \xE–\x1F\16–\37control codes ≠00000000000032 \x20\40space 0≠0≠0≠00000000033–47 \x21–\x2F\41–\57!"#$%&'()*+,-./0≠000≠0≠000000048–57 \x30–\x39\60–\7101234567890≠000≠00≠0000≠0≠058–64 \x3A–\x40\72–\100:;<=>?@0≠000≠0≠000000065–70 \x41–\x46\101–\106ABCDEF0≠000≠00≠0≠0≠000≠071–90 \x47–\x5A\107–\132GHIJKLMNOP
QRSTUVWXYZ0≠000≠00≠0≠0≠000091–96 \x5B–\x60\133–\140[\]^_`0≠000≠0≠000000097–102 \x61–\x66\141–\146abcdef0≠000≠00≠0≠00≠00≠0103–122 \x67–\x7A\147–\172ghijklmnop
qrstuvwxyz0≠000≠00≠0≠00≠000123–126 \x7B–\x7E\172–\176{|}~0≠000≠0≠0000000127 \x7F\177backspace character (DEL) ≠000000000000 Conversions to numeric formats Defined in header

<cstdlib>

atof

converts a byte string to a floating point value
(function)

[edit]

atoiatolatoll

(C++11)

converts a byte string to an integer value
(function)

[edit]

strtolstrtoll

(C++11)

converts a byte string to an integer value
(function)

[edit]

strtoulstrtoull

(C++11)

converts a byte string to an unsigned integer value
(function)

[edit]

strtofstrtodstrtold

converts a byte string to a floating-point value
(function)

[edit]

strfromfstrfromdstrfroml

(C++26)(C++26)(C++26)

converts a floating-point value to a byte string
(function)

[edit]

Defined in header

<cinttypes>

strtoimaxstrtoumax

(C++11)(C++11)

converts a byte string to

std::intmax_t

or

std::uintmax_t

(function)

[edit]

String manipulation Defined in header

<cstring>

strcpy

copies one string to another
(function)

[edit]

strncpy

copies a certain amount of characters from one string to another
(function)

[edit]

strcat

concatenates two strings
(function)

[edit]

strncat

concatenates a certain amount of characters of two strings
(function)

[edit]

strxfrm

transform a string so that strcmp would produce the same result as strcoll
(function)

[edit]

strdup

(C++26)

allocates a copy of a string
(function)

[edit]

strndup

(C++26)

allocates a copy of a string of specified size
(function)

[edit]

String examination Defined in header

<cstring>

strlen

returns the length of a given string
(function)

[edit]

strcmp

compares two strings
(function)

[edit]

strncmp

compares a certain number of characters from two strings
(function)

[edit]

strcoll

compares two strings in accordance to the current locale
(function)

[edit]

strchr

finds the first occurrence of a character
(function)

[edit]

strrchr

finds the last occurrence of a character
(function)

[edit]

strspn

returns the length of the maximum initial segment that consists
of only the characters found in another byte string
(function)

[edit]

strcspn

returns the length of the maximum initial segment that consists
of only the characters not found in another byte string
(function)

[edit]

strpbrk

finds the first location of any character from a set of separators
(function)

[edit]

strstr

finds the first occurrence of a substring of characters
(function)

[edit]

strtok

finds the next token in a byte string
(function)

[edit]

Character array functions Defined in header

<cstring>

memchr

searches an array for the first occurrence of a character
(function)

[edit]

memcmp

compares two buffers
(function)

[edit]

memsetmemset_explicit

(C++26)

fills a buffer with a character
(function)

[edit]

memcpy

copies one buffer to another
(function)

[edit]

memmove

moves one buffer to another
(function)

[edit]

memccpy

(C++26)

copies one buffer to another, stopping after the specified delimiter
(function)

[edit]

Miscellaneous Defined in header

<cstring>

strerror

returns a text version of a given error code
(function)

[edit]

See also