String library functions ----------- summarize some common string processing functions.
Header file: # include
First place
Char * strstr (char * dest, char * need );
Locate the position where the need string appears from the dest string. If the end character is not compared, NULL is not found and the position where the need string is returned is found.
Second place
Char * strcat (char * dest, char * src );
Char * strncat (char * dest, char * src, size_t n );
Add the string pointed to by src to the end of the dest and overwrite the '\ 0' at the end of the string. Return the pointer to the dest. strncat () has one more parameter, is to copy n characters in src. Note: Make sure that the dest has enough space to receive the src!
Third place
Char * strcpy (char * dest, char * src );
Char * strncpy (char * dest, char * src, size_t n );
Copy the content in the src string to the dest, and copy the end mark of the string together. Strncpy () is also a parameter that specifies the number of copied bytes.
Fourth place
Size_t strspn (const char * s, const char * accept );
Size_t strcspn (const char * s, const char * reject );
The strspn function returns the number of characters in the S string that belong to the string's accept from the beginning. In other words, if the strspn function returns n, it indicates that n characters in string S are all characters in string accept from the beginning. In contrast, the strcspn function returns the number of characters in the S string from the beginning that do not belong to the characters in the string accept.
Fifth place
Char * strchr (const char * s, char c );
Char * strrchr (const char * s, char c );
The former is the pointer to the position where the character in c appears for the first time in string S, and the latter is the pointer to the position where the character in c appears for the last time in string S.
Sixth
Char * strdup (const char * s );
Char * strndup (const char * s, size_t n );
Copy the string to the new address, and return the pointer of the new address. The latter adds up to n characters for copying. If the string s exactly contains n characters, the terminator '\ 0' is automatically added.