Detailed C language string functions

void *memset(void *dest, int c, size_t count);
The front dest COUNT character set character C.
The return value of dest.

void *memmove(void *dest, const void *src, size_t count);
Copy character count bytes from src to dest. If src and dest overlap, the function automatically processing
the return value of dest.

void *memcpy(void *dest, const void *src, size_t count);
. Memmove and function as the character count bytes to copy src dest, src and dest just can not deal with duplication.
The return value of dest.

void *memchr(const void *buf, int c, size_t count);
Find in front of buf count bytes in the first occurrence of the character c. C or find a character count bytes have been searched, find stops.
Operating successfully position the pointer buf c of the first occurrence is returned, otherwise returns NULL.

void *_memccpy(void *dest, const void *src, int c, size_t count);
Copying bytes of zero or more characters from src in dest. When the character is copied or c count characters are copied, the copying stops.
If the character c is copied, the function returns a pointer to the next character after the character location. otherwise, it returns NULL.

int memcmp(const void *buf1, const void *buf2, size_t count);
Comparative buf1 and buf2 prior count bytes in size
Returns <0, represents less than buf1 buf2;
returns a value of 0, indicates buf1 equal buf2;
Return value> 0, represents greater than buf1 buf2.

int memicmp(const void *buf1, const void *buf2, size_t count);
Comparative buf1 and buf2 front count bytes. Memcmp the difference it is that it is case insensitive.
Return Value supra.

size_t strlen(const char *string);
Get string length, string, not including the NULL terminator.
No return value indicates an error operation.

char *strrev(char *string);
The order of the characters in the string STRING reversed. NULL terminator same location.
String pointer returned after adjustment.

char *_strupr(char *string);
The string in all lowercase letters into corresponding capital letters Alternatively, other characters remain unchanged.
String pointer returned after adjustment.

char *_strlwr(char *string);
The string replaced in all uppercase letters corresponding lowercase letters, other characters remain unchanged.
String pointer returned after adjustment.

char *strchr(const char *string, int c);
Find the first occurrence of character c in the string of string, NULL terminator is also included in the lookup.
Returns a pointer to the first occurrence of character c in the string string, if not found, NULL is returned.

char *strrchr(const char *string, int c);
Find character c in the string of the last occurrence of the string, which is carried out in reverse order of the search string, containing NULL terminator.
Returns a pointer pointing to the position of the character c in the string of the last occurrence of the string, if not found, NULL is returned.

char *strstr(const char *string, const char *strSearch);
Find the string of string strSearch string.
Returns the substring pointer strSearch position for the first time in string. If the substring strSearch is not found, returns NULL. If the substring strSearch an empty string, the function returns the string value.

char *strdup(const char *strSource);
Space operation functions will call themselves malloc function to allocate to copy a string to copy strSource allocate storage space, and then strSource in. Note to promptly release the allocated space.
Returns a pointer to copy the string space allocated ; If the allocated space fails, NULL value is returned.

char *strcat(char *strDestination, const char *strSource);
The source string appended to the target string strSource strDestination, plus NULL terminator behind the new string obtained. StrSource source string of characters terminated string behind the cover strDestination target symbol NULL. Not Copy string adding process or overflow checking, so to ensure that the target sequence is large enough. not cope with the source string overlaps the target string.
the function returns the value strDestination.

char *strncat(char *strDestination, const char *strSource, size_t count);
After adding the source string strSource starting to count characters of the target string strDest. StrSource source string of characters cover NULL terminator sequence behind strDestination target. If the count is greater than the length of the source string, it will use the source string length value replacement count value behind the new string obtained automatically add NULL terminator. Like strcat function, this function can not handle the case where the source string to a target string overlaps.
the function returns the value strDestination.

char *strcpy(char *strDestination, const char *strSource);
StrSource copy source string to a target string strDestination designated position, comprising a NULL terminator. Where the source string can not be processed and the target sequence overlap.
The function returns the value strDestination.

char *strncpy(char *strDestination, const char *strSource, size_t count);
Copy source string strSource starting to count characters of the target string strDestination specified location. If the count value is less than or equal to the length strSource string, does not automatically add NULL terminator target string, the string count is greater than the length of time strSource, strSource then filled with a NULL terminator fill count characters, copied to the target string. a source string and can not handle the case of overlapping target string.
the function returns the value strDestination.

char *strset(char *string, int c);
Set all character string as a character string c, NULL terminator stop face.
String pointers, the function returns the contents adjusted.

char *strnset(char *string, int c, size_t count);
The string character string is set to start to count characters c, such count value is greater than the length of the string string will be replaced with a count value of the length of the string.
String pointers, the function returns the contents adjusted.

size_t strspn(const char *string, const char *strCharSet);
A find any character string is not included in the strCharSet (except the NULL string terminator) position number first appears in the string string.
Returns an integer value that specifies the length of all sub-string of characters from the character string If the string begins with a character is not included in the strCharSet, the function returns a zero value.

size_t strcspn(const char *string, const char *strCharSet);
A position number to find any character string strCharSet the first occurrence of the string in the string, the string comprising a terminator NULL.
Returns an integer value that specifies the length of the string in a non-all characters of the character substrings. If the string to strCharSet contained in a beginning characters, the function returns a zero value.

char *strspnp(const char *string, const char *strCharSet);
A find any character string is not included in the strCharSet (except the NULL string terminator) position of the pointer first appears in the string string.
Returns a pointer to the position of the non strCharSet first occurrence of the characters in string.

char *strpbrk(const char *string, const char *strCharSet);
Find strCharSet string anywhere in a character string in the first occurrence of the string, the string does not contain the terminator NULL.
Returns a pointer to any position strCharSet a first occurrence of the character in string. If both strings contain parameters the same characters, NULL value is returned.

int strcmp(const char *string1, const char *string2);
Comparing character strings string1 and string2 size
Returns <0, string1 is less than string2;
returns a value of 0, string1 is equal to string2;
Return value> 0, string1 is greater than string2.

int stricmp(const char *string1, const char *string2);
String2 string1 compare strings and size, and strcmp different, the comparison is lowercase versions thereof.
The return value is the same strcmp.

int strcmpi(const char *string1, const char *string2);
Stricmp function is equivalent to just a backwards compatible version.

int strncmp(const char *string1, const char *string2, size_t count);
String2 string1 compare strings and size, only the count of characters of the foregoing comparison. In the comparison process, a string of any length less than the count, the count will be substituted by the shorter length of the string. In this case, if the preceding two strings of characters are equal, the smaller the shorter string.
returns <0, represents the sub-strings less than string1 substring of string2;
returns a value of 0, indicates the sub-string is equal to the sub-string1 string2 string;
returns a value> 0, represents the string1 substring greater than string2 substring.

int strnicmp(const char *string1, const char *string2, size_t count);
String2 string1 compare strings and size, only the count of characters of the foregoing comparison. Strncmp the difference is that the comparison is lowercase versions thereof.
The return value is the same strncmp.

char *strtok(char *strToken, const char *strDelimit);
Find a mark in strToken string, strDelimit character set is specified in the current search delimiter may encounter call.
Returns a pointer to the next token found in the strToken in. If you can not find the mark, it returns NULL value. each call will modify strToken content, each delimiter character is replaced with NULL encountered.

发布了21 篇原创文章 · 获赞 11 · 访问量 2万+

Guess you like

Origin blog.csdn.net/hexf9632/article/details/95167612