In fact, string operations are not part of programming in Linux. However, because programming in Linux is basically the programming of C language function libraries, it is essential to understand strings.
Strcasecmp
Function prototype: int strcasecmp (const char * S1, const char * S2)
Function: Compare ARGs [0] And ARGs [1], regardless of Case sensitivity.
Function return: If the return value is the same, 0 is returned. If the return value is S1 long, a positive number is returned. If the return value is S2 long, a negative number is returned.
Function parameters: S1 and S2 are the two strings to be compared.
Declaration file: String. h
Strcat
Function prototype: char * strcat (char * DEST, const char * SRC );
Function: connect the SRC string to the back of the Dest string. DeST requires sufficient space.
Function return: the first address of the Dest string.
Function parameter: DEST is the first address of the target string, and SRC is the first address of the source string.
Declaration file: String. h
Strchr
Function prototype: char * strchr (const char * STR, int ch );
Function: locate the location of the first ch character in the STR string.
Function return: the location of the CH character that appears for the first time.
Function parameter: STR is the first address of the string, and CH is the character to be searched.
Declaration file: String. h
Strcmp
Function prototype: int strcmp (const char * S1, const char * S2 );
Function: Compares string S1 and string S2. If the two are the same, 0 is returned. If S1 is different from S2, returns the subtract value of the first different S1 and S2 characters.
Function return: if the two are the same, 0 is returned. If S1 is different from S2, the first different S1 and S2 characters are returned, corresponding values after subtraction.
Function parameters: S1 and S2 are the two strings to be compared.
Declaration file: String. h
Strcpy
Function prototype: int strcpy (char * DEST, const char * SRC );
Function: copy the content of the SRC string to the position indicated by DeST.
Function return: the first address of the Dest string.
Function parameter: DEST is the first address of the target string, and SRC is the first address of the source string.
Declaration file: String. h
Strlen
Function prototype: size_t strlen (const char * Str );
Function: calculates the length of a specified string, excluding the ending character "\ 0 ".
Function return: the length of the STR string (excluding the number of characters including "\ 0 ).
Function parameter: String Of the length to be calculated.
Declaration file: String. h
Strstr
Function prototype: char * strstr (const char * STR, const char * substr );
Function: Search for the starting position of the first substring that matches the substr In the STR string.
Function return: Start position of the substring that matches the substr.
Function parameter: STR is the string to be scanned, and substr is the string to be searched.
Declaration file: String. h