C string function Summary

Source: Internet
Author: User

4. memccpy

Prototype: extern void * memccpy (void * dest, void * src, unsigned char ch, unsigned int count );

Usage: # include <string. h>
 
Function: the data is copied from the memory area indicated by src to the memory area indicated by dest. If the ch character is encountered, the data is stopped.
 
Note: The pointer pointing to the first character after the ch character is returned. If ch does not exist in the First n Bytes of src, NULL is returned. Ch is copied.

5. memchr

Prototype: extern void * memchr (void * buf, char ch, unsigned count );

Usage: # include <string. h>
 
Function: searches for the character ch from the first count bytes of the memory area specified by buf.
 
Note: When the first ch character is encountered, stop searching. If the call succeeds, a pointer to the ch character is returned; otherwise, NULL is returned.

6. memicmp

Prototype: extern int memicmp (void * buf1, void * buf2, unsigned int count );

Usage: # include <string. h>
 
Function: Compares the first count bytes of the buf1 and buf2 in the memory region, but does not distinguish uppercase and lowercase letters.
 
Note: The only difference between memicmp and memcmp is that memicmp is case-insensitive.
When buf1 <buf2, return value <0
When buf1 = buf2, the return value is 0.
When buf1> buf2, the return value is greater than 0.
7. memmove

Prototype: extern void * memmove (void * dest, const void * src, unsigned int count );

Usage: # include <string. h>
 
Function: copy count bytes from the memory area indicated by src to the memory area indicated by dest.
 
Note: src and dest indicate that the memory areas can overlap, but the src content will be changed after replication. The function returns a pointer to dest.

8. memset

Prototype: extern void * memset (void * buffer, int c, int count );

Usage: # include <string. h>
 
Function: sets the first count byte of the memory area referred to by buffer to character c.
 
Note: The pointer to the buffer is returned.

9. movmem

Prototype: extern void movmem (void * src, void * dest, unsigned int count );

Usage: # include <string. h>
 
Function: copy count bytes from the memory area indicated by src to the memory area indicated by dest.
 
Note: src and dest indicate that the memory areas can overlap, but the src content will be changed after replication. The function returns a pointer to dest.

10. setmem

Prototype: extern void setmem (void * buf, unsigned int count, char ch );

Usage: # include <string. h>
 
Function: sets the count byte before the memory area referred to by buf to the ch character.
 
Returns the pointer to the buf.


11. stpcpy

Prototype: extern char * stpcpy (char * dest, char * src );

Usage: # include <string. h>
 
Function: Copies the string ending with NULL indicated by src to the array indicated by dest.
 
Note: The memory areas specified by src and dest cannot overlap and dest must have sufficient space to accommodate src strings.
Returns the pointer pointing to the end of the dest character (NULL.
12. prototype: extern char * strcat (char * dest, char * src );

Usage: # include <string. h>
 
Function: add the src string to the end of dest (overwrite '\ 0' at the end of dest) and add' \ 0 '.
 
Note: The memory areas specified by src and dest cannot overlap and dest must have sufficient space to accommodate src strings.
Returns the pointer to dest.
13. strchr

Prototype: extern char * strchr (char * s, char c );

Usage: # include <string. h>
 
Function: locate the first occurrence of character c in string s.
 
Note: return the pointer at the first occurrence of c. If c does not exist in s, return NULL.

14. strcmp

Prototype: extern int strcmp (char * s1, char * s2 );

Usage: # include <string. h>
 
Function: Compares s1 and s2 strings.
 
Note:
When s1 <s2, return value <0
When s1 = s2, the return value is 0.
When s1> s2, return value> 0

15. strcmpi

Prototype: extern int stricmp (char * s1, char * s2 );

Usage: # include <string. h>
 
Function: Compares s1 and s2 strings, but does not distinguish between uppercase and lowercase letters.
 
Note: strcmpi is the macro definition to stricmp. This function is not provided in reality.
When s1 <s2, return value <0
When s1 = s2, the return value is 0.
When s1> s2, return value> 0
16. strcpy

Prototype: extern char * strcpy (char * dest, char * src );

Usage: # include <string. h>
 
Function: Copies the string ending with NULL indicated by src to the array indicated by dest.
 
Note: The memory areas specified by src and dest cannot overlap and dest must have sufficient space to accommodate src strings.
Returns the pointer to dest.

17. strcspns

Prototype: extern int strcspn (char * s1, char * s2 );

Usage: # include <string. h>
 
Function: Search for characters in S2.
 
Note: The Return Value of the first occurrence character in s1, that is, the length of the substring that appears in s1 but does not exist in s2.

18. strdup

Prototype: extern char * strdup (char * s );

Usage: # include <string. h>
 
Function: Copy string s
 
Note: The pointer to the copied string is returned. The space required is allocated by malloc () and can be released by free.

19. stricmp

Prototype: extern int stricmp (char * s1, char * s2 );

Usage: # include <string. h>
 
Function: Compares s1 and s2 strings, but does not distinguish between uppercase and lowercase letters.
 
Note: strcmpi is the macro definition to stricmp. This function is not provided in reality.
When s1 <s2, return value <0
When s1 = s2, the return value is 0.
When s1> s2, return value> 0

20. strlen

Prototype: extern int strlen (char * s );

Usage: # include <string. h>
 
Function: calculates the length of string s.
 
Description: return the length of s, excluding the terminator NULL.

21. strlwr

Prototype: extern char * strlwr (char * s );

Usage: # include <string. h>
 
Function: converts string s to lowercase.
 
Note: Only uppercase letters in s are converted, and other characters are not changed. Returns the pointer to s.

22. strncat

Prototype: extern char * strncat (char * dest, char * src, int n );

Usage: # include <string. h>
 
Function: add the first n characters of the string referred to by src to the end of dest (overwrite '\ 0' at the end of dest) and add' \ 0 '.
 
Note: The memory areas specified by src and dest cannot overlap and dest must have sufficient space to accommodate src strings.
Returns the pointer to dest.

23. strncmp

Prototype: extern int strcmp (char * s1, char * s2, int n );

Usage: # include <string. h>
 
Function: Compares the first n characters of string s1 and s2.
 
Note:
When s1 <s2, return value <0
When s1 = s2, the return value is 0.
When s1> s2, return value> 0
24. strncmpi

Prototype: extern int strnicmp (char * s1, char * s2, int n );

Usage: # include <string. h>
 
Function: Compares the first n characters of string s1 and string s2, but is case insensitive.
 
Note: strncmpi is a macro definition to strnicmp.
When s1 <s2, return value <0
When s1 = s2, the return value is 0.
When s1> s2, return value> 0
25. strncpy

Prototype: extern char * strncpy (char * dest,


From Yongzheng's first class, my faith!

Related Article

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.