String functions as provided by string.h
in the C standard library.
More...
|
char * | strchrnul (const char *s, int c) |
| Find the first occurrence of a character in a string. More...
|
|
char * | strchr (const char *s, int c) |
| Find the first occurrence of a character in a string. More...
|
|
int | strcmp (const char *s1, const char *s2) |
| Compare two strings. More...
|
|
int | strncmp (const char *s1, const char *s2, size_t n) |
| Compare two strings. More...
|
|
size_t | strlen (const char *s) |
| Calculate the length of a string. More...
|
|
char * | strcpy (char *dest, const char *src) |
| Copy the contents of a string including the terminating null byte (\0 ) More...
|
|
char * | strncpy (char *dest, const char *src, size_t n) |
| Copy the contents of a string up to a maximum length or the terminating null byte (\0 ), whatever comes first. More...
|
|
void * | memcpy (void *__restrict__ dest, void const *__restrict__ src, size_t size) |
| Copy a memory area. More...
|
|
void * | memmove (void *dest, void const *src, size_t size) |
| Copy a memory area while the source may overlap with the destination. More...
|
|
void * | memset (void *dest, int pattern, size_t size) |
| Fill a memory area with a pattern. More...
|
|
String functions as provided by string.h
in the C standard library.
◆ memcpy()
void * memcpy |
( |
void *__restrict__ |
dest, |
|
|
void const *__restrict__ |
src, |
|
|
size_t |
size |
|
) |
| |
Copy a memory area.
- Parameters
-
dest | destination buffer |
src | source buffer |
size | number of bytes to copy |
- Returns
- pointer to destination
- Note
- The memory must not overlap!
◆ memmove()
void * memmove |
( |
void * |
dest, |
|
|
void const * |
src, |
|
|
size_t |
size |
|
) |
| |
Copy a memory area while the source may overlap with the destination.
- Parameters
-
dest | destination buffer |
src | source buffer |
size | number of bytes to copy |
- Returns
- pointer to destination
◆ memset()
void * memset |
( |
void * |
dest, |
|
|
int |
pattern, |
|
|
size_t |
size |
|
) |
| |
Fill a memory area with a pattern.
- Parameters
-
dest | destination buffer |
pattern | single byte pattern |
size | number of bytes to fill with pattern |
- Returns
- pointer to destination
◆ strchr()
char * strchr |
( |
const char * |
s, |
|
|
int |
c |
|
) |
| |
Find the first occurrence of a character in a string.
- Parameters
-
s | string to |
c | character to find |
- Returns
- Pointer to first occurrence of the character or to nullptr if not found
◆ strchrnul()
char * strchrnul |
( |
const char * |
s, |
|
|
int |
c |
|
) |
| |
Find the first occurrence of a character in a string.
- Parameters
-
s | string to |
c | character to find |
- Returns
- Pointer to first occurrence of the character or to null byte at the end of the string if not found
◆ strcmp()
int strcmp |
( |
const char * |
s1, |
|
|
const char * |
s2 |
|
) |
| |
Compare two strings.
- Parameters
-
s1 | first string |
s2 | second string |
- Returns
- an integer less than, equal to, or greater than zero if first string is found, respectively, to be less than, to match, or be greater than second string
◆ strcpy()
char * strcpy |
( |
char * |
dest, |
|
|
const char * |
src |
|
) |
| |
Copy the contents of a string including the terminating null byte (\0
)
- Parameters
-
dest | destination string buffer |
src | source string buffer |
- Returns
- a pointer to the destination string buffer
- Note
- Beware of buffer overruns!
◆ strlen()
size_t strlen |
( |
const char * |
s | ) |
|
Calculate the length of a string.
- Parameters
-
- Returns
- number of bytes in the string
◆ strncmp()
int strncmp |
( |
const char * |
s1, |
|
|
const char * |
s2, |
|
|
size_t |
n |
|
) |
| |
Compare two strings.
- Parameters
-
s1 | first string |
s2 | second string |
n | number of bytes to compare |
- Returns
- an integer less than, equal to, or greater than zero if the given number of bytes of the first string are found, respectively, to be less than, to match, or be greater than second string
◆ strncpy()
char * strncpy |
( |
char * |
dest, |
|
|
const char * |
src, |
|
|
size_t |
n |
|
) |
| |
Copy the contents of a string up to a maximum length or the terminating null byte (\0
), whatever comes first.
- Parameters
-
dest | destination string buffer |
src | source string buffer |
n | maximum number of bytes to copy |
- Returns
- a pointer to the destination string buffer
- Note
- If there is no null byte (
\0
) among the first n
bytes, the destination will not be null-terminated!