Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

C Standard Library – <string.h>


May 11, 2021 C


Table of contents


C Standard Library - slt;string.h>

Brief introduction

The string .h header file defines a function of a variable type, a macro, and an array of various operational characters.

Library variables

Here are the types of variables defined in the header file string.h:

Serial number Variable & description
1 size_t
This is an unsigned integer type, it is sizeof The result of the keyword.

Library macros

Here are the macros defined in the header file string.h:

Serial number Macro & Description
1 NULL
This macro is a value of an empty pointer.

The library function

Here 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)
Parameter str Search for the first time C (an unsigned character) in the first N byte of the string pointed to.
2 int memcmp(const void *str1, const void *str2, size_t n)
Bundle str1 with str2 The first N bytes 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 str2 Copy n characters to str1 The function.
5 void *memset(void *str, int c, size_t n)
Copy Character C (A Non-symbolic character) to parameters str The first n characters of the polar string pointed to.
6 char *strcat(char *dest, const char *src)
Bundle src The string pointed to dest The end of the string pointed to.
7 char *strncat(char *dest, const char *src, size_t n)
Bundle src The string pointed to dest The end of the string pointing until the N-character length.
8 char *strchr(const char *str, int c)
Parameter str Search in the character string to search for the first time character c (a unsigned character) position.
9 int strcmp(const char *str1, const char *str2)
Bundle str1 The string pointed to str2 The point to the string is compared.
10 int strncmp(const char *str1, const char *str2, size_t n)
Bundle str1 with str2 Compare, up to the previous N bytes.
11 int strcoll(const char *str1, const char *str2)
Bundle str1 with str2 Comparison, the result depends on the location setting of LC_COLLATE.
12 char *strcpy(char *dest, const char *src)
Bundle src Copy the string pointed to dest
13 char *strncpy(char *dest, const char *src, size_t n)
Bundle src Copy the string pointed to dest Copy N characters up to.
14 size_t strcspn(const char *str1, const char *str2)
Retrieving string STR1 does not contain characters in string STR2 in a row.
15 char *strerror(int errnum)
Search for error number errnum from the internal array and returns a pointer to the error message string.
16 size_t strlen(const char *str)
Calculate the length of the string STR until the empty end character, but does not include empty end characters.
17 char *strpbrk(const char *str1, const char *str2)
Retrieve string str1 The first matching string str2 The characters of the Chinese characters do not include empty end characters.That is, the characters in the string STR1 are verified in turn, and when the character is also included in the string STR2, the test is stopped and the character position is returned.
18 char *strrchr(const char *str, int c)
Parameter str Search in the character string in the point to search for the last appearance character C (a unsigned character) position.
19 size_t strspn(const char *str1, const char *str2)
Retrieve string str1 The first one is not in the string str2 The characters that appear in the middle.
20 char *strstr(const char *haystack, const char *needle)
String haystack Find the first string needle (Do not include empty end characters).
21 char *strtok(char *str, const char *delim)
Decomposition string str For a set of strings, delim Separator.
22 size_t strxfrm(char *dest, const char *src, size_t n)
Convert strings based on LC_COLLLATE in the current area option src Before n Character and place them in strings dest middle.