String library functions in C Language

Source: Internet
Author: User

String library functions in C Language
The following is an excerpt from "C program design tutorial" (US), translated by h.m. deitel P. J. deitel, and translated by Xue Wanpeng, the mechanical industry press.

Void * memccpy (void * DEST, const void * SRC, int C, size_t N );
Copy n characters from the object pointed to by Src to the object pointed to by DeST. If character C is encountered during the replication process, stop the replication and return the pointer pointing to the next position of character C in DEST; otherwise, return null.

Void * memcpy (void * DEST, const void * SRC, size_t N );
Copy n characters from the object pointed to by Src to the object pointed to by DeST. Returns the value of the pointer DeST.

Void * memchr (const void * s, int C, size_t N );
Search for the character C in the first n characters of the object to which s points. If it is found, the Pointer Points to the position where character C appears for the first time; otherwise, null is returned.

Int memcmp (const void * S1, const void * S2, size_t N );
Compare the first n characters of the objects pointed to by S1 and the objects pointed to by S2. The returned value is the first character difference between S1 and S2.

Int memicmp (const void * S1, const void * S2, size_t N );
Compare the first n characters of the objects pointed to by S1 and S2, regardless of case. The returned value is the first character difference between S1 and S2.

Void * memmove (void * DEST, const void * SRC, size_t N );
Copy n characters from the object pointed to by Src to the object pointed to by DeST. Returns the value of the pointer DeST. No memory overlap occurs.

Void * memset (void * s, int C, size_t N );
Set the first n characters of the object to which s points to C. Returns the value of S as the pointer.

Char * stpcpy (char * DEST, const char * SRC );
Copy the SRC string to DeST. Returns the value of the pointer DEST + Len (SRC.

Char * strcpy (char * DEST, const char * SRC );
Copy the SRC string to DeST. Returns the value of the pointer DeST.

Char * strcat (char * DEST, const char * SRC );
Add the SRC string to the end of DeST. Returns the value of the pointer DeST.

Char * strchr (const char * s, int C );
Search for character C in string S. If it is found, the Pointer Points to the position where character C appears for the first time; otherwise, null is returned.

Int strcmp (const char * S1, const char * S2 );
Compares string S1 and string S2. The returned value is the first character difference between S1 and S2.

Int stricmp (const char * S1, const char * S2 );
Compares string S1 and string S2, regardless of Case sensitivity. The returned value is the first character difference between S1 and S2.

Size_t strcspn (const char * S1, const char * S2 );
The return value is the initial String Length of string S1, which is completely composed of characters not contained in string S2.

Size_t strspn (const char * S1, const char * S2 );
The return value is the initial String Length of string S1, which is completely composed of characters contained in string S2.

Char * strdup (const char * s );
Returns the copy of string S. Returns the first address of the copied string.

Char * strerror (INT errnum );
Returns the first address of the error message string associated with errnum. For the macro definition of errnum, see errno. h.

Size_t strlen (const char * s );
The returned value is the length of string S. The Terminator '/0' is not included ′.

Char * strlwr (char * s );
Converts all string s to lowercase letters. Returns the value of S as the pointer.

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

Char * strncat (char * DEST, const char * SRC, size_t maxlen );
Add the SRC string to the end of the DeST. A maximum of maxlen characters can be added. Returns the value of the pointer DeST.

Int strncmp (const char * S1, const char * S2, size_t maxlen );
Compares string S1 and string S2 with a maximum of maxlen characters. The returned value is the first character difference between S1 and S2.

Char * strncpy (char * DEST, const char * SRC, size_t maxlen );
Copy the SRC string to DeST. A maximum of maxlen characters can be copied. Returns the value of the pointer DeST.

Int strnicmp (const char * S1, const char * S2, size_t maxlen );
Compares string S1 and string S2. It is case-insensitive and can contain a maximum of maxlen characters. The returned value is the first character difference between S1 and S2.

Char * strnset (char * s, int CH, size_t N );
Set the first n characters in string s to all characters C. Returns the value of S as the pointer.

Char * strset (char * s, int ch );
Set all characters in string s to C. Returns the value of S as the pointer.

Char * strpbrk (const char * S1, const char * S2 );
Returns the position of the first occurrence of any character of string S2 in string S1. If no occurrence is returned, null is returned.

Char * strrchr (const char * s, int C );
Search for character C in string S. If it is found, the pointer pointing to the position where character C was last appeared; otherwise, null is returned.

Char * strrev (char * s );
Returns the string that points to the flipped string.

Char * strstr (const char * S1, const char * S2 );
Search string S2. If it is found, the pointer is directed to the position where string S2 first appeared; otherwise, null is returned.

Char * strtok (char * S1, const char * S2 );
Use the characters in string S2 as separators to separate string S1. Returns the pointer to the split string. After the first call, use nulll instead of S1 as the first parameter.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/beitcoder/archive/2008/03/11/2171024.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.