C Standard Library - <string.h>
Introduction
string .h The header file defines a variable type, a macro and various functions for operating character arrays.
Library variables
The following are the variable types defined in the header file string.h:
Serial number | Variables & Description |
---|---|
1 | size_t This is the unsigned integer type, which is the sizeof keyword result. |
Library macros
The following are the macros defined in the header file string.h:
Serial number | Macro & Description |
---|---|
1 | NULL This macro is the value of a null pointer constant. |
Library functions
The following are the functions defined in the header file string.h:
Serial number | Function & Description |
---|---|
1 | void *memchr(const void *str, int c, size_t n) Search for the first occurrence of character c (an unsigned character) in the first n bytes of the string pointed to by parameter str. |
2 | int memcmp(const void *str1, const void *str2, size_t n) Put str1 and The first n bytes of str2 are compared. |
3 | void *memcpy(void *dest, const void *src, size_t n) Copy n characters from src to dest. |
4 | void *memmove(void *dest, const void *src, size_t n) Another one is used to read from str2 Function to copy n characters to str1. |
5 | void *memset(void *str, int c, size_t n) Copy character c (an unsigned character) to the parameter The first n characters of the string pointed to by str. |
6 | char *strcat(char *dest, const char *src) Append the string pointed to by src to dest The end of the string pointed to. |
7 | char *strncat(char *dest, const char *src, size_t n) Put the character pointed to by src The string is appended to the end of the string pointed to by dest until it is n characters in length. |
8 | char *strchr(const char *str, int c) Search in the string pointed to by the parameter str The position of the first occurrence of character c (an unsigned character). |
9 | int strcmp(const char *str1, const char *str2) Sum the string pointed to by str1 and str2 The strings pointed to are compared. |
10 | int strncmp(const char *str1, const char *str2, size_t n) Put str1 and str2 Compares up to the first n bytes. |
11 | int strcoll(const char *str1, const char *str2) Put str1 and str2 Compare, the result depends on the position setting of LC_COLLATE. |
12 | char *strcpy(char *dest, const char *src) Copy the string pointed to by src to dest. |
13 | char *strncpy(char *dest, const char *src, size_t n) Put the character pointed to by src Copy the string to dest, up to n characters. |
14 | size_t strcspn(const char *str1, const char *str2) Retrieve the string str1. There are several consecutive characters at the beginning that do not contain the string. Characters in str2. |
15 | char *strerror(int errnum) Search the error number errnum from the internal array and return a pointer to the error message string. |
16 | size_t strlen(const char *str) Calculate the length of string str up to, but not including, the null terminating character. |
17 | char *strpbrk(const char *str1, const char *str2) Retrieves the first character in the string str1 that matches the characters in the string str2, excluding the null terminating character. That is to say, the characters in the string str1 are tested sequentially. When the character being tested is also included in the string str2, the test stops and the character position is returned. |
18 | char *strrchr(const char *str, int c) Search in the string pointed to by the parameter str The position of the last occurrence of character c (an unsigned character). |
19 | size_t strspn(const char *str1, const char *str2) Retrieve the first string in str1 that is not in Character subscript appearing in the string str2. |
20 | char *strstr(const char *haystack, const char *needle) Find the first string haystack The position of the first occurrence of the string needle (excluding the null terminating character). |
21 | char *strtok(char *str, const char *delim) Decompose a stringstr into a set of strings , delim is the delimiter. |
22 | size_t strxfrm(char *dest, const char *src, size_t n) Convert the string according to LC_COLLATE in the current regional option of the program The first n characters of src and place them in the string dest. |