Namespaces
Variants
Views
Actions

Difference between revisions of "c/string/byte"

From cppreference.com
< c‎ | string
m (Shorten template names. Use {{lc}} where appropriate.)
m (fmt.)
 
(13 intermediate revisions by 6 users not shown)
Line 2: Line 2:
 
{{c/string/byte/navbar}}
 
{{c/string/byte/navbar}}
  
A null-terminated byte string (NTBS) is a 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 {{c|{'\x63','\x61','\x74','\0'}}} is an NTBS holding the string {{c|"cat"}} in ASCII encoding.
+
A null-terminated byte string (NTBS) is a 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 {{c|{'\x63','\x61','\x74','\0'}<!---->}} is an NTBS holding the string {{c|"cat"}} in {{lt|c/language/ascii|ASCII}} encoding.
  
 
===Functions===
 
===Functions===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc h2 | Character classification}}
+
{{dsc h2|Character classification}}
{{dsc header | ctype.h}}
+
{{dsc header|ctype.h}}
{{dsc inc | c/string/byte/dcl list isalnum}}
+
{{dsc inc|c/string/byte/dsc isalnum}}
{{dsc inc | c/string/byte/dcl list isalpha}}
+
{{dsc inc|c/string/byte/dsc isalpha}}
{{dsc inc | c/string/byte/dcl list islower}}
+
{{dsc inc|c/string/byte/dsc islower}}
{{dsc inc | c/string/byte/dcl list isupper}}
+
{{dsc inc|c/string/byte/dsc isupper}}
{{dsc inc | c/string/byte/dcl list isdigit}}
+
{{dsc inc|c/string/byte/dsc isdigit}}
{{dsc inc | c/string/byte/dcl list isxdigit}}
+
{{dsc inc|c/string/byte/dsc isxdigit}}
{{dsc inc | c/string/byte/dcl list iscntrl}}
+
{{dsc inc|c/string/byte/dsc iscntrl}}
{{dsc inc | c/string/byte/dcl list isgraph}}
+
{{dsc inc|c/string/byte/dsc isgraph}}
{{dsc inc | c/string/byte/dcl list isspace}}
+
{{dsc inc|c/string/byte/dsc isspace}}
{{dsc inc | c/string/byte/dcl list isblank}}
+
{{dsc inc|c/string/byte/dsc isblank}}
{{dsc inc | c/string/byte/dcl list isprint}}
+
{{dsc inc|c/string/byte/dsc isprint}}
{{dsc inc | c/string/byte/dcl list ispunct}}
+
{{dsc inc|c/string/byte/dsc ispunct}}
  
{{dsc h2 | Character manipulation}}
+
{{dsc h2|Character manipulation}}
{{dsc inc | c/string/byte/dcl list tolower}}
+
{{dsc inc|c/string/byte/dsc tolower}}
{{dsc inc | c/string/byte/dcl list toupper}}
+
{{dsc inc|c/string/byte/dsc toupper}}
 
{{dsc end}}
 
{{dsc end}}
 +
 +
Note: additional functions whose names begin with either {{ttb|to}} or {{ttb|is}}, followed by a lowercase letter, may be added to the header {{tt|ctype.h}} in future and should not be defined by programs that include that header.
 +
 
{{c/string/character classes}}
 
{{c/string/character classes}}
 
{{dsc begin}}
 
{{dsc begin}}
  
{{dsc h2 | Conversions to numeric formats}}
+
{{dsc h2|Conversions to and from numeric formats}}
{{dsc header | stdlib.h}}
+
{{dsc header|stdlib.h}}
{{dsc inc | c/string/byte/dcl list atof}}
+
{{dsc inc|c/string/byte/dsc atof}}
{{dsc inc | c/string/byte/dcl list atoi}}
+
{{dsc inc|c/string/byte/dsc atoi}}
{{dsc inc | c/string/byte/dcl list strtol}}
+
{{dsc inc|c/string/byte/dsc strtol}}
{{dsc inc | c/string/byte/dcl list strtoul}}
+
{{dsc inc|c/string/byte/dsc strtoul}}
{{dsc inc | c/string/byte/dcl list strtof}}
+
{{dsc inc|c/string/byte/dsc strtof}}
{{dsc header | inttypes.h}}
+
{{dsc inc|c/string/byte/dsc strfromf}}
{{dsc inc | c/string/byte/dcl list strtoimax}}
+
{{dsc header|inttypes.h}}
 +
{{dsc inc|c/string/byte/dsc strtoimax}}
  
{{dsc h2 | String manipulation}}
+
{{dsc h2|String manipulation}}
{{dsc header | string.h}}
+
{{dsc header|string.h}}
{{dsc inc | c/string/byte/dcl list strcpy}}
+
{{dsc inc|c/string/byte/dsc strcpy}}
{{dsc inc | c/string/byte/dcl list strncpy}}
+
{{dsc inc|c/string/byte/dsc strncpy}}
{{dsc inc | c/string/byte/dcl list strcat}}
+
{{dsc inc|c/string/byte/dsc strcat}}
{{dsc inc | c/string/byte/dcl list strncat}}
+
{{dsc inc|c/string/byte/dsc strncat}}
{{dsc inc | c/string/byte/dcl list strxfrm}}
+
{{dsc inc|c/string/byte/dsc strxfrm}}
 +
{{dsc inc|c/string/byte/dsc strdup}}
 +
{{dsc inc|c/string/byte/dsc strndup}}
  
{{dsc h2 | String examination}}
+
{{dsc h2|String examination}}
{{dsc header | string.h}}
+
{{dsc header|string.h}}
{{dsc inc | c/string/byte/dcl list strlen}}
+
{{dsc inc|c/string/byte/dsc strlen}}
{{dsc inc | c/string/byte/dcl list strcmp}}
+
{{dsc inc|c/string/byte/dsc strcmp}}
{{dsc inc | c/string/byte/dcl list strncmp}}
+
{{dsc inc|c/string/byte/dsc strncmp}}
{{dsc inc | c/string/byte/dcl list strcoll}}
+
{{dsc inc|c/string/byte/dsc strcoll}}
{{dsc inc | c/string/byte/dcl list strchr}}
+
{{dsc inc|c/string/byte/dsc strchr}}
{{dsc inc | c/string/byte/dcl list strrchr}}
+
{{dsc inc|c/string/byte/dsc strrchr}}
{{dsc inc | c/string/byte/dcl list strspn}}
+
{{dsc inc|c/string/byte/dsc strspn}}
{{dsc inc | c/string/byte/dcl list strcspn}}
+
{{dsc inc|c/string/byte/dsc strcspn}}
{{dsc inc | c/string/byte/dcl list strpbrk}}
+
{{dsc inc|c/string/byte/dsc strpbrk}}
{{dsc inc | c/string/byte/dcl list strstr}}
+
{{dsc inc|c/string/byte/dsc strstr}}
{{dsc inc | c/string/byte/dcl list strtok}}
+
{{dsc inc|c/string/byte/dsc strtok}}
  
{{dsc h2 | Character array manipulation}}
+
{{dsc h2|Character array manipulation}}
{{dsc header | string.h}}
+
{{dsc header|string.h}}
{{dsc inc | c/string/byte/dcl list memchr}}
+
{{dsc inc|c/string/byte/dsc memchr}}
{{dsc inc | c/string/byte/dcl list memcmp}}
+
{{dsc inc|c/string/byte/dsc memcmp}}
{{dsc inc | c/string/byte/dcl list memset}}
+
{{dsc inc|c/string/byte/dsc memset}}
{{dsc inc | c/string/byte/dcl list memcpy}}
+
{{dsc inc|c/string/byte/dsc memcpy}}
{{dsc inc | c/string/byte/dcl list memmove}}
+
{{dsc inc|c/string/byte/dsc memmove}}
 +
{{dsc inc|c/string/byte/dsc memccpy}}
  
{{dsc h2 | Miscellaneous}}
+
{{dsc h2|Miscellaneous}}
{{dsc header | string.h}}
+
{{dsc header|string.h}}
{{dsc inc | c/string/byte/dcl list strerror}}
+
{{dsc inc|c/string/byte/dsc strerror}}
 +
{{dsc end}}
 +
 
 +
===References===
 +
{{ref std c23}}
 +
{{ref std|section=7.4|title=Character handling <ctype.h>|p=TBD}}
 +
{{ref std|section=7.8|title=Format conversion of integer types <inttypes.h>|p=TBD}}
 +
{{ref std|section=7.22|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=7.24|title=String handling <string.h>|p=TBD}}
 +
{{ref std|section=7.31.2|title=Character handling <ctype.h>|p=TBD}}
 +
{{ref std|section=7.31.5|title=Format conversion of integer types <inttypes.h>|p=TBD}}
 +
{{ref std|section=7.31.12|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=7.31.13|title=String handling <string.h>|p=TBD}}
 +
{{ref std|section=K.3.6|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=K.3.7|title=String handling <string.h>|p=TBD}}
 +
{{ref std end}}
 +
{{ref std c17}}
 +
{{ref std|section=7.4|title=Character handling <ctype.h>|p=TBD}}
 +
{{ref std|section=7.8|title=Format conversion of integer types <inttypes.h>|p=TBD}}
 +
{{ref std|section=7.22|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=7.24|title=String handling <string.h>|p=TBD}}
 +
{{ref std|section=7.31.2|title=Character handling <ctype.h>|p=TBD}}
 +
{{ref std|section=7.31.5|title=Format conversion of integer types <inttypes.h>|p=TBD}}
 +
{{ref std|section=7.31.12|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=7.31.13|title=String handling <string.h>|p=TBD}}
 +
{{ref std|section=K.3.6|title=General utilities <stdlib.h>|p=TBD}}
 +
{{ref std|section=K.3.7|title=String handling <string.h>|p=TBD}}
 +
{{ref std end}}
 +
{{ref std c11}}
 +
{{ref std|section=7.4|title=Character handling <ctype.h>|p=200-204}}
 +
{{ref std|section=7.8|title=Format conversion of integer types <inttypes.h>|p=217-220}}
 +
{{ref std|section=7.22|title=General utilities <stdlib.h>|p=340-360}}
 +
{{ref std|section=7.24|title=String handling <string.h>|p=362-372}}
 +
{{ref std|section=7.31.2|title=Character handling <ctype.h>|p=455}}
 +
{{ref std|section=7.31.5|title=Format conversion of integer types <inttypes.h>|p=455}}
 +
{{ref std|section=7.31.12|title=General utilities <stdlib.h>|p=456}}
 +
{{ref std|section=7.31.13|title=String handling <string.h>|p=456}}
 +
{{ref std|section=K.3.6|title=General utilities <stdlib.h>|p=604-613}}
 +
{{ref std|section=K.3.7|title=String handling <string.h>|p=614-623}}
 +
{{ref std end}}
 +
{{ref std c99}}
 +
{{ref std|section=7.4|title=Character handling <ctype.h>|p=181-185}}
 +
{{ref std|section=7.8|title=Format conversion of integer types <inttypes.h>|p=198-201}}
 +
{{ref std|section=7.20|title=General utilities <stdlib.h>|p=306-324}}
 +
{{ref std|section=7.21|title=String handling <string.h>|p=325-334}}
 +
{{ref std|section=7.26.2|title=Character handling <ctype.h>|p=401}}
 +
{{ref std|section=7.26.4|title=Format conversion of integer types <inttypes.h>|p=401}}
 +
{{ref std|section=7.26.10|title=General utilities <stdlib.h>|p=402}}
 +
{{ref std|section=7.26.11|title=String handling <string.h>|p=402}}
 +
{{ref std end}}
 +
{{ref std c89}}
 +
{{ref std|section=4.3|title=CHARACTER HANDLING <ctype.h>}}
 +
{{ref std|section=4.10|title=GENERAL UTILITIES <stdlib.h>}}
 +
{{ref std|section=4.11|title=STRING HANDLING <string.h>}}
 +
{{ref std|section=4.13.2|title=Character handling <ctype.h>}}
 +
{{ref std|section=4.13.7|title=General utilities <stdlib.h>}}
 +
{{ref std|section=4.13.8|title=String handling <string.h>}}
 +
{{ref std end}}
 +
 
 +
===See also===
 +
{{dsc begin}}
 +
{{dsc see cpp|cpp/string/byte|{{tt|Null}}-terminated byte strings|nomono=true}}
 
{{dsc end}}
 
{{dsc end}}
  
[[de:c/string/byte]]
+
{{langlinks|ar|cs|de|es|fr|it|ja|ko|pl|pt|ru|tr|zh}}
[[es:c/string/byte]]
+
[[fr:c/string/byte]]
+
[[it:c/string/byte]]
+
[[ja:c/string/byte]]
+
[[pt:c/string/byte]]
+
[[ru:c/string/byte]]
+
[[zh:c/string/byte]]
+

Latest revision as of 10:15, 7 October 2024

A null-terminated byte string (NTBS) is a 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.

Contents

[edit] Functions

Character classification
Defined in header <ctype.h>
checks if a character is alphanumeric
(function) [edit]
checks if a character is alphabetic
(function) [edit]
checks if a character is lowercase
(function) [edit]
checks if a character is an uppercase character
(function) [edit]
checks if a character is a digit
(function) [edit]
checks if a character is a hexadecimal character
(function) [edit]
checks if a character is a control character
(function) [edit]
checks if a character is a graphical character
(function) [edit]
checks if a character is a space character
(function) [edit]
checks if a character is a blank character
(function) [edit]
checks if a character is a printing character
(function) [edit]
checks if a character is a punctuation character
(function) [edit]
Character manipulation
converts a character to lowercase
(function) [edit]
converts a character to uppercase
(function) [edit]

Note: additional functions whose names begin with either to or is, followed by a lowercase letter, may be added to the header ctype.h in future and should not be defined by programs that include that header.

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\10 control codes (NUL, etc.) ≠0 0 0 0 0 0 0 0 0 0 0 0
9 \x9 \11 tab (\t) ≠0 0 ≠0 ≠0 0 0 0 0 0 0 0 0
10–13 \xA\xD \12\15 whitespaces (\n, \v, \f, \r) ≠0 0 ≠0 0 0 0 0 0 0 0 0 0
14–31 \xE\x1F \16\37 control codes ≠0 0 0 0 0 0 0 0 0 0 0 0
32 \x20 \40 space 0 ≠0 ≠0 ≠0 0 0 0 0 0 0 0 0
33–47 \x21\x2F \41\57 !"#$%&'()*+,-./ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
48–57 \x30\x39 \60\71 0123456789 0 ≠0 0 0 ≠0 0 ≠0 0 0 0 ≠0 ≠0
58–64 \x3A\x40 \72\100 :;<=>?@ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
65–70 \x41\x46 \101\106 ABCDEF 0 ≠0 0 0 ≠0 0 ≠0 ≠0 ≠0 0 0 ≠0
71–90 \x47\x5A \107\132 GHIJKLMNOP
QRSTUVWXYZ
0 ≠0 0 0 ≠0 0 ≠0 ≠0 ≠0 0 0 0
91–96 \x5B\x60 \133\140 [\]^_` 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
97–102 \x61\x66 \141\146 abcdef 0 ≠0 0 0 ≠0 0 ≠0 ≠0 0 ≠0 0 ≠0
103–122 \x67\x7A \147\172 ghijklmnop
qrstuvwxyz
0 ≠0 0 0 ≠0 0 ≠0 ≠0 0 ≠0 0 0
123–126 \x7B\x7E \173\176 {|}~ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
127 \x7F \177 backspace character (DEL) ≠0 0 0 0 0 0 0 0 0 0 0 0
Conversions to and from numeric formats
Defined in header <stdlib.h>
converts a byte string to a floating-point value
(function) [edit]
converts a byte string to an integer value
(function) [edit]
converts a byte string to an integer value
(function) [edit]
converts a byte string to an unsigned integer value
(function) [edit]
converts a byte string to a floating-point value
(function) [edit]
converts a floating-point value to a byte string
(function) [edit]
Defined in header <inttypes.h>
converts a byte string to intmax_t or uintmax_t
(function) [edit]
String manipulation
Defined in header <string.h>
copies one string to another
(function) [edit]
copies a certain amount of characters from one string to another
(function) [edit]
concatenates two strings
(function) [edit]
concatenates a certain amount of characters of two strings
(function) [edit]
transform a string so that strcmp would produce the same result as strcoll
(function) [edit]
(C23)
allocates a copy of a string
(function) [edit]
allocates a copy of a string of specified size
(function) [edit]
String examination
Defined in header <string.h>
returns the length of a given string
(function) [edit]
compares two strings
(function) [edit]
compares a certain amount of characters of two strings
(function) [edit]
compares two strings in accordance to the current locale
(function) [edit]
finds the first occurrence of a character
(function) [edit]
finds the last occurrence of a character
(function) [edit]
returns the length of the maximum initial segment that consists
of only the characters found in another byte string
(function) [edit]
returns the length of the maximum initial segment that consists
of only the characters not found in another byte string
(function) [edit]
finds the first location of any character in one string, in another string
(function) [edit]
finds the first occurrence of a substring of characters
(function) [edit]
finds the next token in a byte string
(function) [edit]
Character array manipulation
Defined in header <string.h>
searches an array for the first occurrence of a character
(function) [edit]
compares two buffers
(function) [edit]
fills a buffer with a character
(function) [edit]
copies one buffer to another
(function) [edit]
moves one buffer to another
(function) [edit]
copies one buffer to another, stopping after the specified delimiter
(function) [edit]
Miscellaneous
Defined in header <string.h>
returns a text version of a given error code
(function) [edit]

[edit] References

  • C23 standard (ISO/IEC 9899:2024):
  • 7.4 Character handling <ctype.h> (p: TBD)
  • 7.8 Format conversion of integer types <inttypes.h> (p: TBD)
  • 7.22 General utilities <stdlib.h> (p: TBD)
  • 7.24 String handling <string.h> (p: TBD)
  • 7.31.2 Character handling <ctype.h> (p: TBD)
  • 7.31.5 Format conversion of integer types <inttypes.h> (p: TBD)
  • 7.31.12 General utilities <stdlib.h> (p: TBD)
  • 7.31.13 String handling <string.h> (p: TBD)
  • K.3.6 General utilities <stdlib.h> (p: TBD)
  • K.3.7 String handling <string.h> (p: TBD)
  • C17 standard (ISO/IEC 9899:2018):
  • 7.4 Character handling <ctype.h> (p: TBD)
  • 7.8 Format conversion of integer types <inttypes.h> (p: TBD)
  • 7.22 General utilities <stdlib.h> (p: TBD)
  • 7.24 String handling <string.h> (p: TBD)
  • 7.31.2 Character handling <ctype.h> (p: TBD)
  • 7.31.5 Format conversion of integer types <inttypes.h> (p: TBD)
  • 7.31.12 General utilities <stdlib.h> (p: TBD)
  • 7.31.13 String handling <string.h> (p: TBD)
  • K.3.6 General utilities <stdlib.h> (p: TBD)
  • K.3.7 String handling <string.h> (p: TBD)
  • C11 standard (ISO/IEC 9899:2011):
  • 7.4 Character handling <ctype.h> (p: 200-204)
  • 7.8 Format conversion of integer types <inttypes.h> (p: 217-220)
  • 7.22 General utilities <stdlib.h> (p: 340-360)
  • 7.24 String handling <string.h> (p: 362-372)
  • 7.31.2 Character handling <ctype.h> (p: 455)
  • 7.31.5 Format conversion of integer types <inttypes.h> (p: 455)
  • 7.31.12 General utilities <stdlib.h> (p: 456)
  • 7.31.13 String handling <string.h> (p: 456)
  • K.3.6 General utilities <stdlib.h> (p: 604-613)
  • K.3.7 String handling <string.h> (p: 614-623)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.4 Character handling <ctype.h> (p: 181-185)
  • 7.8 Format conversion of integer types <inttypes.h> (p: 198-201)
  • 7.20 General utilities <stdlib.h> (p: 306-324)
  • 7.21 String handling <string.h> (p: 325-334)
  • 7.26.2 Character handling <ctype.h> (p: 401)
  • 7.26.4 Format conversion of integer types <inttypes.h> (p: 401)
  • 7.26.10 General utilities <stdlib.h> (p: 402)
  • 7.26.11 String handling <string.h> (p: 402)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 4.3 CHARACTER HANDLING <ctype.h>
  • 4.10 GENERAL UTILITIES <stdlib.h>
  • 4.11 STRING HANDLING <string.h>
  • 4.13.2 Character handling <ctype.h>
  • 4.13.7 General utilities <stdlib.h>
  • 4.13.8 String handling <string.h>

[edit] See also

C++ documentation for Null-terminated byte strings