C language String library

xiaoxiao2021-03-06  17

In C language, the processing of strings is very important, especially in some network devices, the processing process will affect the forwarding and throughput of the device. All functions in String.h are detailed here. The following is taken from the "C programming tutorial" (US) h.m.deitel p.j.deitel, Xue Wanpeng and other translation, mechanical industry publishing house.

Void * Memccpy (Void * Dest, const void * src, int c, size_t n); copy n characters to the object pointing to DEST from the object pointing to the SRC. If the character c is encountered during the copy, the copy is stopped, and the pointer points to the next position in the character C in Dest; otherwise returns NULL.

Void * Memcpy (Void * Dest, const void * src, size_t n); copy n characters to the object pointing to DEST from the object pointing to the SRC. Returns the value of the pointer to DEST.

Void * Memchr (const void * s, int c, size_t n); Search character c in front n characters of the object pointed to by S. If search, the return pointer points to the position of the character C for the first time; otherwise returns NULL.

INT MEMCMP (const void * s1, const void * s2, size_t n); compares the first n characters of the objects indicted to the S1 and the objects indicted to S2. The return value is the first different character difference between S1 and S2.

INT MEMICMP (const void * s1, const void * s2, size_t n); compares the first n characters of the objects indicted by S1 and the objects indicted to S2, ignore cases. The return value is the first different character difference between S1 and S2.

Void * Memmove (Void * Dest, const void * src, size_t n); copy n characters to the object pointing to DEST from the object pointing to the SRC. Returns the value of the pointer to DEST. Memory overlap will not occur.

Void * MEMSET (Void * S, INT C, SIZE_T N); the first n characters of the object pointing to the S are character c. Returns the value of the pointer to S.

Char * stpcpy (char * DEST, Const Char * src); Copy string SRC to DEST. Returns the value of the pointer to DEST LEN (SRC).

Char * STRCPY (CHAR * DEST, CONST Char * src); Copy string SRC to DEST. Returns the value of the pointer to DEST.

Char * STRCAT (CHAR * DEST, Const Char * SRC); Add the string SRC to the DEST tail. Returns the value of the pointer to DEST.

Char * strchr (const char * s, int c); Search character c in string s. If search, the return pointer points to the position of the character C for the first time; otherwise returns NULL.

INT STRCMP (const char * s1, const char * s2); compare strings S1 and string S2. The return value is the first different character difference between S1 and S2.

INT STRICMP (const char * s1, const char * s2); compare strings S1 and string S2, ignore cases. The return value is the first different character difference between S1 and S2.

SIZE_T STRCSPN (const char * s1, const char * s2); return value is the initial string length of the string S1 consisting of characters that do not contain characters in the string S2.

SIZE_T STRSPN (const char * s1, const char * s2); return value is the initial string length of the string S1 composed of characters contained in the string S2.

Char * strdup (const char * s); obtains a replication of a string S. Returns the first address of the string that points to the replication. Char * strerror (int errnum); return pointer points to the first address of the error message string associated by Errnum. Errnum macro definition See errno.h. SIZE_T STRLEN (const char * s); return value is the length of string S. Does not include end values ​​'/ 0'.

Char * strlwr (char * s); transitions all string s into lowercase. Returns the value of the pointer to S.

Char * strupr (char * s); all converts the string s to uppercase. Returns the value of the pointer to S.

Char * Strncat (Char * DEST, Const Char * SRC, SIZE_T MAXLEN); adds string src to the end of the DEST and adds maximum of Maxlen characters. Returns the value of the pointer to DEST.

INT STRNCMP (const char * s1, const char * s2, size_t maxlen); compare strings S1 and string S2, the maximum Maxlen characters are compared. The return value is the first different character difference between S1 and S2.

Char * STRNCPY (CHAR * DEST, Const Char * src, size_t maxlen); Copy string SRC to DEST, copy Maxlen characters. Returns the value of the pointer to DEST.

INT STRNICMP (const char * s1, const char * s2, size_t maxlen); Compare strings S1 and string S2, ignore cases, and compare max of Maxlen characters. The return value is the first different character difference between S1 and S2.

Char * strnset (CHAR * S, INT CH, SIZE_T N); Setting the first n characters in the string S are all character c. Returns the value of the pointer to S.

Char * strset (CHAR * S, INT CH); setting characters in string s all character c. Returns the value of the pointer to S.

CHAR * STRPBRK (const char * s1, const char * s2); Returns the position of any character of the string S2 in the string S1 first appears; if no NULL is returned.

Char * Strrchr (const char * s, int c); Search character c in string s. If search, the return pointer points to the position of the last appearance of character c; otherwise returns NULL.

Char * Strrev (Char * S); all flips the strings, returns the poke the string of flip.

CHAR * STRSTR (const char * s1, const char * s2); Search string S2 in string S1. If search, the return pointer points to the first time the string S2; otherwise returns NULL.

CHAR * STRTOK (Char * S1, Const Char * S2); Separator S1 is divided by using characters in string S2. Returns the pointer points to the split string. After the first call, you need to replace S1 as the first parameter with NULLL.

转载请注明原文地址:https://www.9cbs.com/read-41248.html

New Post(0)