string.h

The libc string header

Author

Martin ‘Solar’ Baute

License

Public Domain

Defines

memchr memcmp memcpy memmove memset strcat strchr strcmp strcoll strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtok strxfrm

Linker Parameters

-lc

void * memchr(const void *s,
int c,
size_t n)
Finds the first occurance of the character c in s, where n is the maximum amount of bytes to compare
int memcmp(const void *s1,
const void *s2,
size_t n)
Compares n bytes of s1 to n bytes of s2
void * memcpy(void * _PDCLIB_restrict s1,
const void * _PDCLIB_restrict s2,
size_t n)
Copies n bytes from s2 to s1, where s1 and s2 do not overlap
void * memmove(void *s1,
const void *s2,
size_t n)
Copies n bytes from s2 to s1, where s2 and s1 can overlap
void * memset(void *s,
int c,
size_t n)
Fills s with n times the value c
char * strcat(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2)
Appends the null terminated string s2 to the end of s1
char * strchr(const char *s,
int c)
Finds the first occurance of the character c in the null-terminated string s
int strcmp(const char *s1,
const char *s2)
Compares s1 to s2
int strcoll(const char *s1,
const char *s2)
Compares s1 to s2
char * strcpy(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2)
Copies the null terminated string s2 to s1
size_t strcspn(const char *s1,
const char *s2)
Tests characters in s1 for an occurance in s2 until a match is found
size_t strlen(const char *s)
Calculates the length of s
char * strncat(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2,
size_t n)
Appends up to n characters from the null terminated string s2 to the end of s1.
int strncmp(const char *s1,
const char *s2,
size_t n)
Compares at most n bytes of s1 to s2
char * strncpy(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2,
size_t n)
Copies the null terminated string s2 to s1, up to n characters The remaining space, if any, is filled with zeroes
char * strpbrk(const char *s1,
const char *s2)
Finds the first character in s1 that occurs in s2
char * strrchr(const char *s,
int c)
Finds the last character in s that matches c
size_t strspn(const char *s1,
const char *s2)
Tests characters in s1 for an occurance in s2 until no match is found
char * strstr(const char *s1,
const char *s2)
Finds the first occurance of s1 in s2
char * strtok(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2)
Split s1 on each and any character in s2 Supply NULL to continue searching the previous string.
size_t strxfrm(char * _PDCLIB_restrict s1,
const char * _PDCLIB_restrict s2,
size_t n)
Copies the null terminated string s2 to s1, if s2 is not more than n bytes long